· 4 years ago · Mar 31, 2021, 02:54 PM
1create database if not exists db_homework_3;
2
3create table if not exists db_homework_3.order(
4 order_id int auto_increment primary key,
5 created_at timestamp
6 not null default '0000-00-00 00:00:00'
7 default current_timestamp
8);
9
10create table if not exists db_homework_3.product(
11 product_id int auto_increment primary key,
12 product_name varchar(25),
13 price int
14);
15
16create table if not exists db_homework_3.order_product(
17 order_id int,
18 product_id int,
19 constraint fk_order_product_to_order
20 foreign key (order_id)
21 references db_homework_3.order (order_id),
22 constraint fk_order_product_to_product
23 foreign key (product_id)
24 references db_homework_3.product (product_id),
25 constraint pk_order_product
26 primary key (order_id, product_id)
27);