Created
November 19, 2016 18:49
-
-
Save pkozlovskiy/16fe73a7073c3c82bc81c082443c0f84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE document( | |
_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | |
name TEXT NOT NULL, | |
); | |
CREATE TABLE tag( | |
_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | |
name TEXT NOT NULL | |
); | |
CREATE TABLE document_tags( | |
document_id INTEGER NOT NULL, | |
tag_id INTEGER NOT NULL, | |
PRIMARY KEY(document_id, tag_id), | |
FOREIGN KEY (document_id) REFERENCES document(_id) ON DELETE CASCADE, | |
FOREIGN KEY (tag_id) REFERENCES tag(_id) ON DELETE CASCADE | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment