Moved comments from removed Database Architecture writeboard into schema.sql
This commit is contained in:
parent
9e75fc2589
commit
8a56951c0b
1 changed files with 16 additions and 0 deletions
16
schema.sql
16
schema.sql
|
@ -8,6 +8,7 @@
|
||||||
DROP INDEX IF EXISTS schema;
|
DROP INDEX IF EXISTS schema;
|
||||||
CREATE INDEX schema ON version(schema);
|
CREATE INDEX schema ON version(schema);
|
||||||
|
|
||||||
|
-- The foundational table; every item collected has a unique record here
|
||||||
DROP TABLE IF EXISTS items;
|
DROP TABLE IF EXISTS items;
|
||||||
CREATE TABLE items (
|
CREATE TABLE items (
|
||||||
itemID INTEGER PRIMARY KEY,
|
itemID INTEGER PRIMARY KEY,
|
||||||
|
@ -17,12 +18,15 @@
|
||||||
dateModified DATETIME DEFAULT CURRENT_TIMESTAMP
|
dateModified DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Valid item types ("book," "journalArticle," etc.)
|
||||||
DROP TABLE IF EXISTS itemTypes;
|
DROP TABLE IF EXISTS itemTypes;
|
||||||
CREATE TABLE itemTypes (
|
CREATE TABLE itemTypes (
|
||||||
itemTypeID INTEGER PRIMARY KEY,
|
itemTypeID INTEGER PRIMARY KEY,
|
||||||
typeName TEXT
|
typeName TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Describes various types of fields and their format restrictions,
|
||||||
|
-- and indicates whether data should be stored as strings or integers
|
||||||
DROP TABLE IF EXISTS fieldFormats;
|
DROP TABLE IF EXISTS fieldFormats;
|
||||||
CREATE TABLE fieldFormats (
|
CREATE TABLE fieldFormats (
|
||||||
fieldFormatID INTEGER PRIMARY KEY,
|
fieldFormatID INTEGER PRIMARY KEY,
|
||||||
|
@ -30,6 +34,7 @@
|
||||||
isInteger INT
|
isInteger INT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Field types for item metadata
|
||||||
DROP TABLE IF EXISTS fields;
|
DROP TABLE IF EXISTS fields;
|
||||||
CREATE TABLE fields (
|
CREATE TABLE fields (
|
||||||
fieldID INTEGER PRIMARY KEY,
|
fieldID INTEGER PRIMARY KEY,
|
||||||
|
@ -38,6 +43,7 @@
|
||||||
FOREIGN KEY (fieldFormatID) REFERENCES fieldFormat(fieldFormatID)
|
FOREIGN KEY (fieldFormatID) REFERENCES fieldFormat(fieldFormatID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Defines valid fields for each itemType and their display order
|
||||||
DROP TABLE IF EXISTS itemTypeFields;
|
DROP TABLE IF EXISTS itemTypeFields;
|
||||||
CREATE TABLE itemTypeFields (
|
CREATE TABLE itemTypeFields (
|
||||||
itemTypeID INT,
|
itemTypeID INT,
|
||||||
|
@ -48,6 +54,7 @@
|
||||||
FOREIGN KEY (fieldID) REFERENCES itemTypes(itemTypeID)
|
FOREIGN KEY (fieldID) REFERENCES itemTypes(itemTypeID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Type-specific data for individual items
|
||||||
DROP TABLE IF EXISTS itemData;
|
DROP TABLE IF EXISTS itemData;
|
||||||
CREATE TABLE itemData (
|
CREATE TABLE itemData (
|
||||||
itemID INT,
|
itemID INT,
|
||||||
|
@ -60,6 +67,7 @@
|
||||||
DROP INDEX IF EXISTS value;
|
DROP INDEX IF EXISTS value;
|
||||||
CREATE INDEX value ON itemData(value);
|
CREATE INDEX value ON itemData(value);
|
||||||
|
|
||||||
|
-- Note data for note items
|
||||||
DROP TABLE IF EXISTS itemNotes;
|
DROP TABLE IF EXISTS itemNotes;
|
||||||
CREATE TABLE itemNotes (
|
CREATE TABLE itemNotes (
|
||||||
itemID INT,
|
itemID INT,
|
||||||
|
@ -98,6 +106,7 @@
|
||||||
DROP INDEX IF EXISTS fileTypeMimeTypes_mimeType;
|
DROP INDEX IF EXISTS fileTypeMimeTypes_mimeType;
|
||||||
CREATE INDEX fileTypeMimeTypes_mimeType ON fileTypeMimeTypes(mimeType);
|
CREATE INDEX fileTypeMimeTypes_mimeType ON fileTypeMimeTypes(mimeType);
|
||||||
|
|
||||||
|
-- File data for file items
|
||||||
DROP TABLE IF EXISTS itemFiles;
|
DROP TABLE IF EXISTS itemFiles;
|
||||||
CREATE TABLE itemFiles (
|
CREATE TABLE itemFiles (
|
||||||
itemID INT,
|
itemID INT,
|
||||||
|
@ -116,6 +125,7 @@
|
||||||
DROP INDEX IF EXISTS itemFiles_mimeType;
|
DROP INDEX IF EXISTS itemFiles_mimeType;
|
||||||
CREATE INDEX itemFiles_mimeType ON itemFiles(mimeType);
|
CREATE INDEX itemFiles_mimeType ON itemFiles(mimeType);
|
||||||
|
|
||||||
|
-- Individual entries for each tag
|
||||||
DROP TABLE IF EXISTS tags;
|
DROP TABLE IF EXISTS tags;
|
||||||
CREATE TABLE tags (
|
CREATE TABLE tags (
|
||||||
tagID INT,
|
tagID INT,
|
||||||
|
@ -123,6 +133,7 @@
|
||||||
PRIMARY KEY (tagID)
|
PRIMARY KEY (tagID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Associates items with keywords
|
||||||
DROP TABLE IF EXISTS itemTags;
|
DROP TABLE IF EXISTS itemTags;
|
||||||
CREATE TABLE itemTags (
|
CREATE TABLE itemTags (
|
||||||
itemID INT,
|
itemID INT,
|
||||||
|
@ -145,6 +156,7 @@
|
||||||
DROP INDEX IF EXISTS itemSeeAlso_linkedItemID;
|
DROP INDEX IF EXISTS itemSeeAlso_linkedItemID;
|
||||||
CREATE INDEX itemSeeAlso_linkedItemID ON itemSeeAlso(linkedItemID);
|
CREATE INDEX itemSeeAlso_linkedItemID ON itemSeeAlso(linkedItemID);
|
||||||
|
|
||||||
|
-- Names of each individual "creator" (inc. authors, editors, etc.)
|
||||||
DROP TABLE IF EXISTS creators;
|
DROP TABLE IF EXISTS creators;
|
||||||
CREATE TABLE creators (
|
CREATE TABLE creators (
|
||||||
creatorID INT,
|
creatorID INT,
|
||||||
|
@ -153,12 +165,14 @@
|
||||||
PRIMARY KEY (creatorID)
|
PRIMARY KEY (creatorID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Defines the possible creator types (contributor, editor, author)
|
||||||
DROP TABLE IF EXISTS creatorTypes;
|
DROP TABLE IF EXISTS creatorTypes;
|
||||||
CREATE TABLE creatorTypes (
|
CREATE TABLE creatorTypes (
|
||||||
creatorTypeID INTEGER PRIMARY KEY,
|
creatorTypeID INTEGER PRIMARY KEY,
|
||||||
creatorType TEXT
|
creatorType TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Associates single or multiple creators to items
|
||||||
DROP TABLE IF EXISTS itemCreators;
|
DROP TABLE IF EXISTS itemCreators;
|
||||||
CREATE TABLE itemCreators (
|
CREATE TABLE itemCreators (
|
||||||
itemID INT,
|
itemID INT,
|
||||||
|
@ -171,6 +185,7 @@
|
||||||
FOREIGN KEY (creatorTypeID) REFERENCES creatorTypes(creatorTypeID)
|
FOREIGN KEY (creatorTypeID) REFERENCES creatorTypes(creatorTypeID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Collections (a.k.a. "projects") for holding items
|
||||||
DROP TABLE IF EXISTS collections;
|
DROP TABLE IF EXISTS collections;
|
||||||
CREATE TABLE collections (
|
CREATE TABLE collections (
|
||||||
collectionID INT,
|
collectionID INT,
|
||||||
|
@ -180,6 +195,7 @@
|
||||||
FOREIGN KEY (parentCollectionID) REFERENCES collections(collectionID)
|
FOREIGN KEY (parentCollectionID) REFERENCES collections(collectionID)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Associates items with the various collections they belong to
|
||||||
DROP TABLE IF EXISTS collectionItems;
|
DROP TABLE IF EXISTS collectionItems;
|
||||||
CREATE TABLE collectionItems (
|
CREATE TABLE collectionItems (
|
||||||
collectionID INT,
|
collectionID INT,
|
||||||
|
|
Loading…
Reference in a new issue