-
Notifications
You must be signed in to change notification settings - Fork 1
/
Queries.txt
88 lines (84 loc) · 2.06 KB
/
Queries.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
CREATE DATABASE IF NOT EXISTS `tsec_hackathon`;
USE `tsec_hackathon`;
CREATE TABLE `users`
(
`id` int NOT NULL AUTO_INCREMENT,
`username` varchar
(100) DEFAULT NULL,
`full_name` varchar
(100) DEFAULT NULL,
`email` varchar
(100) DEFAULT NULL,
`mobile_number` varchar
(100) DEFAULT NULL,
`address` varchar
(255) DEFAULT NULL,
`area` varchar
(100) DEFAULT NULL,
`city_with_pincode` varchar
(100) DEFAULT NULL,
`state_name` varchar
(100) DEFAULT NULL,
`password` varchar
(100) DEFAULT NULL,
`role` varchar
(20) DEFAULT 'customer',
`coins` varchar
(20) DEFAULT 50,
PRIMARY KEY
(`id`)
)
CREATE TABLE `items`
(
`id` int NOT NULL AUTO_INCREMENT,
`user_id` int DEFAULT NULL,
`title` varchar
(100) DEFAULT NULL,
`description` varchar
(255) DEFAULT NULL,
`price` varchar
(50) DEFAULT NULL,
`disc_price` varchar
(50) DEFAULT NULL,
`size` varchar
(50) DEFAULT NULL,
`colour` varchar
(50) DEFAULT NULL,
`category` varchar
(50) DEFAULT NULL,
`type` varchar
(50) DEFAULT NULL,
`delivery_in_days` varchar
(20) DEFAULT NULL,
`img_link` varchar(255) DEFAULT NULL,
`seller` varchar(50) DEFAULT NULL,
PRIMARY KEY
(`id`),
KEY `user_id`
(`user_id`),
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE TABLE `cart`
(
`id` int NOT NULL AUTO_INCREMENT,
`user_id` int DEFAULT NULL,
`item_id` int DEFAULT NULL,
`ordered` varchar
(15) DEFAULT False,
PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`item_id`) REFERENCES `items`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
)
CREATE TABLE `orders`
(
`id` int NOT NULL AUTO_INCREMENT,
`user_id` int DEFAULT NULL,
`item_id` int DEFAULT NULL,
`cart_id` int DEFAULT NULL,
`status` varchar
(15) DEFAULT 'ordered',
PRIMARY KEY (`id`),
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`item_id`) REFERENCES `items`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`cart_id`) REFERENCES `cart`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
)