-
Notifications
You must be signed in to change notification settings - Fork 0
/
productDB-demo.sql
52 lines (46 loc) · 1.1 KB
/
productDB-demo.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
create schema if not exists productmanagement collate utf8mb4_0900_ai_ci;
create table if not exists customer
(
id int auto_increment
primary key,
firstname varchar(45) null,
lastname varchar(45) null,
gender bit null,
date_of_birth date null
);
create table if not exists address
(
customer_id int not null
primary key,
city varchar(45) null,
zipcode varchar(45) null,
street varchar(100) null,
constraint customer_pk
foreign key (customer_id) references customer (id)
on update cascade on delete cascade
);
create table if not exists `order`
(
order_id int auto_increment
primary key,
customer_id int not null,
orderDate date null,
price double not null,
constraint custome_fk
foreign key (order_id) references customer (id)
on update cascade on delete cascade
);
create table if not exists product
(
product_id int auto_increment,
name varchar(128) not null,
description varchar(255) not null,
price float not null,
constraint name_UNIQUE
unique (name),
constraint product_id_UNIQUE
unique (product_id)
)
charset=latin1;
alter table product
add primary key (product_id);