Created
April 10, 2017 02:21
-
-
Save andrewrcollins/732326c17e1eec2ce15737d0a06f299d to your computer and use it in GitHub Desktop.
simple tagging
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 tag | |
( | |
id INT(10) unsigned NOT NULL auto_increment, | |
name VARCHAR(255) NOT NULL, | |
PRIMARY KEY (id), | |
UNIQUE KEY tag_name (name) | |
); | |
CREATE TABLE tag_type | |
( | |
id INT(10) unsigned NOT NULL auto_increment, | |
name VARCHAR(255) NOT NULL, | |
PRIMARY KEY (id) | |
); | |
CREATE TABLE tag_object | |
( | |
id INT(10) unsigned NOT NULL auto_increment, | |
tag_id INT(10) unsigned NOT NULL, | |
tag_type_id INT(10) unsigned NOT NULL, | |
object_id INT(10) unsigned NOT NULL, | |
PRIMARY KEY (id), | |
FOREIGN KEY (tag_id) REFERENCES tag(id) ON DELETE CASCADE, | |
FOREIGN KEY (tag_type_id) REFERENCES tag_type(id) ON DELETE CASCADE | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment