-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDatabase_CreatTable.sql
69 lines (64 loc) · 1.65 KB
/
Database_CreatTable.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- ----------------------------
-- drop table
-- ----------------------------
drop table if exists want;
drop table if exists publish;
drop table if exists book;
drop table if exists sort;
drop table if exists users;
-- ----------------------------
-- USER
-- ----------------------------
create table users
(uno numeric(10,0) not null primary key,
ugrade numeric(4,0) not null,
uname varchar(255) not null,
unickname varchar(255) not null,
utel numeric(11,0) not null,
uwechat varchar(255) default null,
uqq varchar(255) default null,
upassword varchar(255) not null,
ustate bit default null,
ulike int default null,
unlike int default null
);
-- ----------------------------
-- SORT
-- ----------------------------
create table sort
(sno int not null primary key AUTO_INCREMENT,
sgrade varchar(255) not null ,
sname varchar(255) not null
);
-- ----------------------------
-- BOOK
-- ----------------------------
create table book
(bno int not null primary key AUTO_INCREMENT,
sno int not null,
bname varchar(255) not null,
create_time varchar(255) not null,
bpicture varchar(255) default null,
bprice int not null,
bdescribe text not null,
bstate bit default null,
foreign key (sno) references sort(sno)
);
-- ----------------------------
-- PUBLISH
-- ----------------------------
create table publish
(uno numeric(10,0) not null,
bno int not null,
foreign key (uno) references users(uno),
foreign key (bno) references book(bno)
);
-- ----------------------------
-- WANT
-- ----------------------------
create table want
(bno int not null,
uno numeric(10,0) not null,
foreign key (bno) references book(bno),
foreign key (uno) references users(uno)
);