forked from niannianli/Shopping-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
65 lines (59 loc) · 1.69 KB
/
database.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**************************/
/* categories */
/* */
/**************************/
CREATE TABLE `categories`
(
`category_id` INT NOT NULL AUTO_INCREMENT,
`category_name` VARCHAR(15) NOT NULL,
PRIMARY KEY (`category_id`),
UNIQUE KEY `category_name` (`category_name`)
) TYPE=MyISAM;
/**************************/
/* products */
/* */
/**************************/
CREATE TABLE `products`
(
`product_id` INT(10) NOT NULL AUTO_INCREMENT,
`category_id` MEDIUMINT(8) NOT NULL,
`product_name` VARCHAR(50) NOT NULL,
`price` DOUBLE NOT NULL,
`detail` TEXT NOT NULL,
`is_commend` TINYINT(1) NOT NULL DEFAULT '0',
`photo` VARCHAR(255) NOT NULL,
`post_datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`product_id`),
KEY `category_id` (`category_id`)
) TYPE=MyISAM;
/**************************/
/* carts */
/* */
/**************************/
CREATE TABLE `carts`
(
`cart_id` INT(10) NOT NULL auto_increment,
`session_id` VARCHAR(32) NOT NULL,
`product_id` INT(10) NOT NULL,
`number` INT(10) NOT NULL,
PRIMARY KEY (`cart_id`),
KEY `session_id` (`session_id`,`product_id`)
) TYPE=MyISAM;
/**************************/
/* orders */
/* */
/**************************/
CREATE TABLE `orders`
(
`order_id` INT(10) NOT NULL,
`session_id` VARCHAR(32) NOT NULL,
`user_name` VARCHAR(40),
`email` VARCHAR(40) NOT NULL,
`address` VARCHAR(200) DEFAULT NULL,
`total_price` DOUBLE NOT NULL,
`postcode` VARCHAR(10) NOT NULL,
`tel_no` VARCHAR(20) NOT NULL,
`content` TEXT NOT NULL,
PRIMARY KEY (`order_id`),
KEY `session_id` (`session_id`)
) TYPE=MyISAM;