This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Version008.txt
199 lines (169 loc) · 9.5 KB
/
Version008.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
Version 8 followed on from Version 7. Changes (as they affect JWLMerge) are as follows:
"Location" Table
Modified KeySymbol NULL (formerly NOT NULL) and associated Check Constraint
New table = "InputField" Table
Here's the v8 schema:
CREATE TABLE "Location" (
LocationId INTEGER NOT NULL PRIMARY KEY,
BookNumber INTEGER,
ChapterNumber INTEGER,
DocumentId INTEGER,
Track INTEGER,
IssueTagNumber INTEGER NOT NULL DEFAULT 0,
KeySymbol TEXT,
MepsLanguage INTEGER NOT NULL,
Type INTEGER NOT NULL,
Title TEXT,
UNIQUE(BookNumber, ChapterNumber, KeySymbol, MepsLanguage, Type),
UNIQUE(KeySymbol, IssueTagNumber, MepsLanguage, DocumentId, Track, Type),
CHECK (
(Type IN (0, 1) AND KeySymbol IS NOT NULL) OR
(Type = 0 AND (DocumentId IS NOT NULL AND DocumentId != 0) AND BookNumber IS NULL AND ChapterNumber IS NULL AND Track IS NULL) OR
(Type = 0 AND DocumentId IS NULL AND (BookNumber IS NOT NULL AND BookNumber != 0) AND (ChapterNumber IS NOT NULL AND ChapterNumber != 0) AND Track IS NULL) OR
(Type = 1 AND BookNumber IS NULL AND ChapterNumber IS NULL AND DocumentId IS NULL AND Track IS NULL) OR
(Type IN (2, 3) AND BookNumber IS NULL AND ChapterNumber IS NULL)
)
);
CREATE TABLE "UserMark" (
UserMarkId INTEGER NOT NULL PRIMARY KEY,
ColorIndex INTEGER NOT NULL,
LocationId INTEGER NOT NULL,
StyleIndex INTEGER NOT NULL,
UserMarkGuid TEXT NOT NULL UNIQUE,
Version INTEGER NOT NULL,
FOREIGN KEY(LocationId) REFERENCES Location(LocationId)
);
CREATE TABLE BlockRange (
BlockRangeId INTEGER NOT NULL PRIMARY KEY,
BlockType INTEGER NOT NULL,
Identifier INTEGER NOT NULL,
StartToken INTEGER,
EndToken INTEGER,
UserMarkId INTEGER NOT NULL,
CHECK (BlockType BETWEEN 1 AND 2),
FOREIGN KEY(UserMarkId) REFERENCES UserMark(UserMarkId)
);
CREATE TABLE "Bookmark" (
BookmarkId INTEGER NOT NULL PRIMARY KEY,
LocationId INTEGER NOT NULL,
PublicationLocationId INTEGER NOT NULL,
Slot INTEGER NOT NULL,
Title TEXT NOT NULL,
Snippet TEXT,
BlockType INTEGER NOT NULL DEFAULT 0,
BlockIdentifier INTEGER,
FOREIGN KEY(LocationId) REFERENCES Location(LocationId),
FOREIGN KEY(PublicationLocationId) REFERENCES Location(LocationId),
CONSTRAINT PublicationLocationId_Slot UNIQUE (PublicationLocationId, Slot),
CHECK((BlockType = 0 AND BlockIdentifier IS NULL) OR ((BlockType BETWEEN 1 AND 2) AND BlockIdentifier IS NOT NULL))
);
CREATE TABLE InputField (
LocationId INTEGER NOT NULL,
TextTag TEXT NOT NULL,
Value TEXT NOT NULL,
FOREIGN KEY (LocationId) REFERENCES Location (LocationId),
CONSTRAINT LocationId_TextTag PRIMARY KEY (LocationId, TextTag)
);
CREATE TABLE LastModified(LastModified TEXT NOT NULL DEFAULT(strftime('%Y-%m-%dT%H:%M:%SZ', 'now')));
CREATE TABLE "Note" (
NoteId INTEGER NOT NULL PRIMARY KEY,
Guid TEXT NOT NULL UNIQUE,
UserMarkId INTEGER,
LocationId INTEGER,
Title TEXT,
Content TEXT,
LastModified TEXT NOT NULL DEFAULT(strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
BlockType INTEGER NOT NULL DEFAULT 0,
BlockIdentifier INTEGER,
CHECK((BlockType = 0 AND BlockIdentifier IS NULL) OR ((BlockType BETWEEN 1 AND 2) AND BlockIdentifier IS NOT NULL)),
FOREIGN KEY(UserMarkId) REFERENCES UserMark(UserMarkId),
FOREIGN KEY(LocationId) REFERENCES Location(LocationId)
);
CREATE TABLE PlaylistMedia(
PlaylistMediaId INTEGER NOT NULL PRIMARY KEY,
MediaType INTEGER NOT NULL,
Label TEXT,
Filename TEXT UNIQUE,
LocationId INTEGER,
FOREIGN KEY(LocationId) REFERENCES Location(LocationId),
CONSTRAINT MediaType_LocationId UNIQUE(MediaType, LocationId),
CHECK(
(LocationId IS NULL AND Filename IS NOT NULL AND Label IS NOT NULL) OR
(LocationId IS NOT NULL AND Filename IS NULL AND Label IS NULL) OR
(LocationId IS NOT NULL AND Filename IS NOT NULL)),
CHECK(MediaType IN(1, 2, 3))
);
CREATE TABLE PlaylistItem(
PlaylistItemId INTEGER NOT NULL PRIMARY KEY,
Label TEXT NOT NULL,
AccuracyStatement INTEGER NOT NULL,
StartTimeOffsetTicks INTEGER,
EndTimeOffsetTicks INTEGER,
EndAction INTEGER NOT NULL,
ThumbnailFilename TEXT,
PlaylistMediaId INTEGER NOT NULL,
FOREIGN KEY(PlaylistMediaId) REFERENCES PlaylistMedia(PlaylistMediaId),
CHECK(length(Label) > 0),
CHECK(AccuracyStatement IN(0, 1, 2, 3)),
CHECK(EndAction IN(0, 1, 2, 3))
);
CREATE TABLE PlaylistItemChild(
PlaylistItemChildId INTEGER NOT NULL PRIMARY KEY,
BaseDurationTicks INTEGER NOT NULL,
MarkerId INTEGER,
MarkerLabel TEXT,
MarkerStartTimeTicks INTEGER,
MarkerEndTransitionDurationTicks INTEGER,
PlaylistItemId INTEGER NOT NULL,
FOREIGN KEY(PlaylistItemId) REFERENCES PlaylistItem(PlaylistItemId),
CHECK(
(MarkerId IS NULL AND MarkerLabel IS NULL AND MarkerStartTimeTicks IS NULL AND MarkerEndTransitionDurationTicks IS NULL) OR
(MarkerId IS NOT NULL AND MarkerLabel IS NOT NULL AND MarkerStartTimeTicks IS NOT NULL)
)
);
CREATE TABLE "Tag" (
TagId INTEGER NOT NULL PRIMARY KEY,
Type INTEGER NOT NULL,
Name TEXT NOT NULL,
ImageFilename TEXT,
UNIQUE(Type, Name),
CHECK(length(Name) > 0),
CHECK(Type IN (0, 1, 2))
);
CREATE TABLE "TagMap" (
TagMapId INTEGER NOT NULL PRIMARY KEY,
PlaylistItemId INTEGER,
LocationId INTEGER,
NoteId INTEGER,
TagId INTEGER NOT NULL,
Position INTEGER NOT NULL,
FOREIGN KEY(TagId) REFERENCES Tag(TagId),
FOREIGN KEY(PlaylistItemId) REFERENCES PlaylistItem(PlaylistItemId),
FOREIGN KEY(LocationId) REFERENCES Location(LocationId),
FOREIGN KEY(NoteId) REFERENCES Note(NoteId),
CONSTRAINT TagId_Position UNIQUE(TagId, Position),
CONSTRAINT TagId_NoteId UNIQUE(TagId, NoteId),
CONSTRAINT TagId_LocationId UNIQUE(TagId, LocationId),
CHECK(
(NoteId IS NULL AND LocationId IS NULL AND PlaylistItemId IS NOT NULL) OR
(LocationId IS NULL AND PlaylistItemId IS NULL AND NoteId IS NOT NULL) OR
(PlaylistItemId IS NULL AND NoteId IS NULL AND LocationId IS NOT NULL))
);
CREATE VIEW PlaylistView AS
SELECT t.Name, t.ImageFilename, Count(tm.TagId) AS ItemCount
FROM Tag t LEFT JOIN TagMap tm ON tm.TagId=t.TagId
WHERE t.Type=2
GROUP BY t.TagId
ORDER BY t.Name COLLATE NOCASE;
CREATE INDEX IX_BlockRange_UserMarkId ON BlockRange(UserMarkId);
CREATE INDEX IX_Location_KeySymbol_MepsLanguage_BookNumber_ChapterNumber ON
Location(KeySymbol, MepsLanguage, BookNumber, ChapterNumber);
CREATE INDEX IX_Location_MepsLanguage_DocumentId ON Location(MepsLanguage, DocumentId);
CREATE INDEX IX_Note_LastModified_LocationId ON Note(LastModified, LocationId);
CREATE INDEX IX_Note_LocationId_BlockIdentifier ON Note(LocationId, BlockIdentifier);
CREATE INDEX IX_TagMap_LocationId_TagId_Position ON TagMap(LocationId, TagId, Position);
CREATE INDEX IX_TagMap_NoteId_TagId_Position ON TagMap(NoteId, TagId, Position);
CREATE INDEX IX_TagMap_PlaylistItemId_TagId_Position ON TagMap(PlaylistItemId, TagId, Position);
CREATE INDEX IX_TagMap_TagId ON TagMap(TagId);
CREATE INDEX IX_Tag_Name_Type_TagId ON Tag(Name, Type, TagId);
CREATE INDEX IX_UserMark_LocationId ON UserMark(LocationId);