@@ -4,36 +4,36 @@ drop table if exists orders;
4
4
drop table if exists products;
5
5
6
6
create table products (
7
- id int not null auto_increment,
8
- title varchar (100 ) not null ,
7
+ id int ( 11 ) not null auto_increment,
8
+ title varchar (100 ) not null default ' ' ,
9
9
description text not null ,
10
- image_url varchar (200 ) not null ,
11
- price decimal (10 ,2 ) not null ,
12
- date_available datetime not null ,
10
+ image_url varchar (200 ) not null default ' ' ,
11
+ price decimal (10 ,2 ) not null default ' 0.00 ' ,
12
+ date_available datetime not null default ' 0000-00-00 00:00:00 ' ,
13
13
primary key (id)
14
14
);
15
15
16
16
/* START:orders*/
17
17
create table orders (
18
- id int not null auto_increment,
18
+ id int ( 11 ) not null auto_increment,
19
19
name varchar (100 ) not null ,
20
20
email varchar (255 ) not null ,
21
21
address text not null ,
22
22
pay_type char (10 ) not null ,
23
- shipped_at datetime null ,
23
+ shipped_at datetime null ,
24
24
primary key (id)
25
25
);
26
26
/* END:orders*/
27
27
28
28
create table line_items (
29
- id int not null auto_increment,
30
- product_id int not null ,
31
- order_id int not null ,
32
- quantity int not null default 0 ,
33
- unit_price decimal (10 ,2 ) not null ,
34
- constraint fk_items_product foreign key (product_id) references products (id),
35
- constraint fk_items_order foreign key (order_id) references orders(id ),
36
- primary key (id )
29
+ id int ( 11 ) not null auto_increment,
30
+ product_id int ( 11 ) not null ,
31
+ order_id int ( 11 ) not null ,
32
+ quantity int ( 11 ) not null default 0 ,
33
+ unit_price decimal (10 ,2 ) not null ,
34
+ primary key (id),
35
+ KEY ` fk_items_product ` ( ` product_id ` ),
36
+ KEY ` fk_items_order ` ( ` order_id ` )
37
37
);
38
38
39
39
0 commit comments