-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelectronics.sql
103 lines (84 loc) · 2.96 KB
/
electronics.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
CREATE TABLE user(
username varchar(40) primary key,
password varchar(40) NOT NULL,
enabled int default 0,
role varchar(40) NOT NULL);
CREATE TABLE customer(
cid varchar(40) primary key,
name varchar(40) NOT NULL,
contact bigint NOT NULL,
email varchar(40) NOT NULL,
house_no int,
locality varchar(40),
city varchar(40),
foreign key (cid) references user(username));
CREATE TABLE partner(
pid varchar(40) primary key,
name varchar(40) NOT NULL,
firm varchar(40),
contact bigint NOT NULL,
email varchar(40) NOT NULL,
foreign key (pid) references user(username));
CREATE TABLE otp(
code varchar(40) primary key,
username varchar(40) NOT NULL,
foreign key (username) references user(username));
CREATE TABLE category(
name varchar(40) primary key,
description varchar(100) NOT NULL);
CREATE TABLE product(
productid int auto_increment primary key,
name varchar(40) NOT NULL,
brand varchar(40) NOT NULL,
price int NOT NULL,
category varchar(40) NOT NULL,
photo varchar(500),
foreign key (category) references category(name));
CREATE TABLE cart(
customerid varchar(40) NOT NULL,
productid int NOT NULL,
quantity int,
primary key (customerid, productid),
foreign key (customerid) references customer(cid),
foreign key (productid) references product(productid));
CREATE TABLE invoice(
id int primary key,
DateOfIssue datetime DEFAULT CURRENT_TIMESTAMP,
paymentmethod varchar(40) default "Payment on receipt",
customerid varchar(40) NOT NULL,
foreign key (customerid) references customer(cid));
CREATE TABLE orders(
orderid int NOT NULL,
productid int NOT NULL,
quantity int NOT NULL,
primary key (orderid, productid),
foreign key (orderid) references invoice(id),
foreign key (productid) references product(productid));
CREATE TABLE partnerproposal(
partnerid varchar(40) NOT NULL,
productid int NOT NULL,
price int NOT NULL,
status varchar(40) default "pending",
primary key (partnerid, productid),
foreign key (partnerid) references partner(pid),
foreign key (productid) references product(productid));
CREATE TABLE feedback(
feedbackid int auto_increment primary key,
username varchar(40) NOT NULL,
rating int NOT NULL,
description varchar(100),
foreign key (username) references user(username));
INSERT into user(username, password, enabled, role)
values('admin','123',1,'ROLE_ADMIN');
INSERT INTO category(name, description)
values ('Laptop','Brand new Laptops');
INSERT INTO category(name, description)
values ('Phone','With new features');
INSERT INTO product(name, brand, price, category, photo)
values ('Macbook','Apple',100000,'Laptop','/resources/images/products/products-1.jpg');
INSERT INTO product(name, brand, price, category, photo)
values ('F1','Xiaomi',20000,'Phone','/resources/images/products/products-6.jpg');
INSERT INTO product(name, brand, price, category, photo)
values ('Chromebook','HP',50000,'Laptop','/resources/images/products/products-2.jpg');
INSERT INTO product(name, brand, price, category, photo)
values ('J5','Samsung',15000,'Phone','/resources/images/products/products-5.jpg');