diff --git a/schema/sources.sql b/schema/sources.sql index 3314573..41bcd57 100644 --- a/schema/sources.sql +++ b/schema/sources.sql @@ -14,3 +14,22 @@ CREATE TABLE sources ( first_party BOOLEAN NOT NULL, ogl_copyright_block TEXT NOT NULL ); + +CREATE TABLE sourceentries ( + sourceentries_id INTEGER PRIMARY KEY, + sources_id INTEGER NOT NULL, + page_start INTEGER, + page_stop INTEGER, + UNIQUE (sources_id, page_start, page_stop), -- prevent duplicates + FOREIGN KEY (sources_id) REFERENCES sources(sources_id) +); + +CREATE TABLE monsters_sourceentries ( + id INTEGER PRIMARY KEY, + monsters_id INTEGER NOT NULL, + sourceentries_id INTEGER NOT NULL, + FOREIGN KEY (monsters_id) REFERENCES monsters(monsters_id), + FOREIGN KEY (sourceentries_id_id) REFERENCES sourceentries_id(sourceentries_id_id) +); + +-- TODO add in new many-to-many tables for the various things we want to have sources be listed this way