· 9 years ago · Dec 26, 2016, 12:29 AM
1
2drop table if exists tags;
3create table tags (
4 id integer primary key,
5 name text not null,
6 description text not null,
7);
8
9drop table if exists taggings;
10create table taggings (
11 id integer primary key,
12 tag_id integer unique,
13 object_id integer unique,
14 unique (tag_id, object_id),
15 foreign key (tag_id) references tags(id),
16 foreign key (object_id) references objects(id),
17);
18
19drop table if exists tag_votes;
20create table tag_votes (
21 tagging_id integer not null,
22 user_id integer not null,
23 is_upvote integer not null,
24 primary key (tagging_id, user_id),
25 foreign key (tagging_id) references taggings(id),
26 foreign key (user_id) references users(id),
27);