-
Notifications
You must be signed in to change notification settings - Fork 0
/
tables.sql
48 lines (48 loc) · 1.13 KB
/
tables.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
create table article_type (
id int not null auto_increment,
name varchar(255),
primary key (id)
);
>>
create table article (
id int not null auto_increment,
title varchar(255) not null,
modifytime timestamp not null default current_timestamp on update current_timestamp,
createtime timestamp not null,
body text,
primary key (id)
);
>>
create table article_article_type (
aid int not null,
tid int not null,
foreign key (aid) references article(id) on delete cascade,
foreign key (tid) references article_type(id) on delete cascade
);
>>
create table album (
id int not null auto_increment,
name varchar(255) not null,
primary key(id)
);
>>
create table photo (
id int not null auto_increment,
intro varchar(255) not null,
file varchar(255) not null,
aid int not null,
primary key (id),
foreign key (aid) references album(id) on delete cascade
);
>>
create table hyperlink (
id int not null auto_increment,
title varchar(255) not null,
http varchar(255) not null,
primary key (id)
);
>>
create trigger set_article_createtime
before insert on article
for each row
set new.createtime=current_timestamp;;