-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sql
More file actions
57 lines (49 loc) · 1.39 KB
/
script.sql
File metadata and controls
57 lines (49 loc) · 1.39 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
create table customer
(
customer_id varchar(10) not null
primary key,
customer_name varchar(20) not null,
customer_address varchar(50) not null,
customer_contact varchar(12) not null
);
create table item
(
item_id varchar(10) not null
primary key,
item_name varchar(20) not null,
item_stock int not null,
item_unit_price decimal(6, 2) not null
);
create table `order`
(
order_id varchar(10) not null
primary key,
order_date date not null,
customer_id varchar(10) null,
total decimal(10, 2) not null,
constraint order_ibfk_1
foreign key (customer_id) references customer (customer_id)
);
create index customer_id
on `order` (customer_id);
create table order_detail
(
order_id varchar(10) not null,
item_id varchar(10) not null,
item_quantity int not null,
item_total decimal(6, 2) not null,
primary key (order_id, item_id),
constraint order_detail_ibfk_1
foreign key (order_id) references `order` (order_id),
constraint order_detail_ibfk_2
foreign key (item_id) references item (item_id)
);
create index item_id
on order_detail (item_id);
create table user
(
user_id int auto_increment
primary key,
user_name varchar(20) not null,
password varchar(10) not null
);