-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdb2018081301003.sql
More file actions
40 lines (35 loc) · 1.06 KB
/
db2018081301003.sql
File metadata and controls
40 lines (35 loc) · 1.06 KB
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
create database db2018081301003;
create table client(
client_no varchar(32) not null,
client_name varchar(5) not null,
client_sex varchar(1) not null,
client_tel varchar(11) not null,
primary key(client_no),
check(client_sex in("男", "女"))
);
create table orderitems
(order_no varchar(32) not null,
client_no varchar(32) not null,
order_time datetime not null,
product_no varchar(32) not null,
order_amount int not null,
primary key(order_no, product_no),
foreign key(product_no)references product(product_no),
foreign key(client_no) references client(client_no)
);
create table product(
product_no varchar(32) not null,
product_name varchar(10) not null,
product_price decimal(18, 2) not null,
product_amount int not null,
primary key(product_no)
);
create table invoice(
invoice_no varchar(32) not null,
invoice_client_no varchar(32) not null,
order_no varchar(32) not null,
invoice_time datetime not null,
primary key(invoice_no),
foreign key (invoice_client_no) references client(client_no),
foreign key (order_no) references orderitems(order_no)
);