forked from AntonyCorbett/JWLMerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Version005.txt
103 lines (86 loc) · 4.4 KB
/
Version005.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
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 NOT NULL,
MepsLanguage INTEGER NOT NULL,
Type INTEGER NOT NULL,
Title TEXT,
CHECK (
(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,
CHECK (LocationId > 0),
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));
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 != 0 AND BlockIdentifier IS NOT NULL)));
CREATE TABLE "Tag" (
TagId INTEGER NOT NULL PRIMARY KEY,
Type INTEGER NOT NULL,
Name TEXT NOT NULL,
UNIQUE (Type, Name),
CHECK (length(Name) > 0));
CREATE TABLE "TagMap" (
TagMapId INTEGER NOT NULL PRIMARY KEY,
Type INTEGER NOT NULL,
TypeId INTEGER NOT NULL,
TagId INTEGER NOT NULL,
Position INTEGER NOT NULL,
FOREIGN KEY(TagId) REFERENCES Tag(TagId)
CONSTRAINT Type_TypeId_TagId_Position UNIQUE (Type, TypeId, TagId, Position));
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_TagId ON TagMap(TagId);
CREATE INDEX IX_TagMap_TypeId_TagId_Position ON TagMap(TypeId, Type, TagId, Position);
CREATE INDEX IX_Tag_Name_Type_TagId ON Tag(Name, Type, TagId);
CREATE INDEX IX_UserMark_LocationId ON UserMark(LocationId);