Skip to content

Instantly share code, notes, and snippets.

@pkozlovskiy
Created November 19, 2016 18:49
Show Gist options
  • Save pkozlovskiy/16fe73a7073c3c82bc81c082443c0f84 to your computer and use it in GitHub Desktop.
Save pkozlovskiy/16fe73a7073c3c82bc81c082443c0f84 to your computer and use it in GitHub Desktop.
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