-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.sql
More file actions
46 lines (42 loc) · 4.25 KB
/
Copy pathcreate.sql
File metadata and controls
46 lines (42 loc) · 4.25 KB
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
create table tb_category (id int8 generated by default as identity, name varchar(255), primary key (id));
create table tb_deliveryman (id int8 generated by default as identity, cpf varchar(255) not null, email varchar(255) not null, name varchar(255) not null, phone varchar(255) not null, primary key (id));
create table tb_order (id int8 generated by default as identity, moment timestamp, status int4, deliveryman_id int8, user_id int8, primary key (id));
create table tb_order_product (order_id int8 not null, product_id int8 not null, primary key (order_id, product_id));
create table tb_product (id int8 generated by default as identity, description varchar(255), name varchar(255), price float8, primary key (id));
create table tb_product_category (product_id int8 not null, category_id int8 not null, primary key (product_id, category_id));
create table tb_user (id int8 generated by default as identity, address varchar(255) not null, cpf varchar(255) not null, date date not null, email varchar(255) not null, name varchar(255) not null, number varchar(255) not null, phone varchar(11) not null, primary key (id));
alter table if exists tb_order add constraint FK3gpnak3l99qrgqrpemxoqyuy3 foreign key (deliveryman_id) references tb_deliveryman;
alter table if exists tb_order add constraint FK2p4n9ciui39792tk5qdpcxq1w foreign key (user_id) references tb_user;
alter table if exists tb_order_product add constraint FKsu03ywlcvyqg5y78qey2q25lc foreign key (product_id) references tb_product;
alter table if exists tb_order_product add constraint FK40anaevs16kmc2tbh7wc511fq foreign key (order_id) references tb_order;
alter table if exists tb_product_category add constraint FK5r4sbavb4nkd9xpl0f095qs2a foreign key (category_id) references tb_category;
alter table if exists tb_product_category add constraint FKgbof0jclmaf8wn2alsoexxq3u foreign key (product_id) references tb_product;
INSERT INTO tb_category(name) values ('PASTA');
INSERT INTO tb_category(name) values ('PIZZA');
INSERT INTO tb_category(name) values ('SANDWICH');
INSERT INTO tb_category(name) values ('DRINK');
INSERT INTO tb_category(name) values ('VEGAN');
INSERT INTO tb_product(name,description,price) values ('SPAGHETTI BOLOGNESE','A DELICIOUS PASTA MADE WITH LOTS OF LOVE',20.00);
INSERT INTO tb_product(name,description,price) values ('SPAGHETTI WITH GARLIC AND OIL','A PERFECT SPAGHETTI FOR YOUR MEAL',25.00);
INSERT INTO tb_product(name,description,price) values ('PEPPERONI PIZZA','A DELICIOUS PEPPERONI PIZZA MADE WITH THE BEST INGREDIENTS',15.00);
INSERT INTO tb_product(name,description,price) values ('MOZZARELLA PIZZA','A DELICIOUS MOZZARELLA PIZZA MADE WITH THE BEST INGREDIENTS',15.00);
INSERT INTO tb_product(name,description,price) values ('X-BURGUER','A DELICIOUS X-BURGUER',10.00);
INSERT INTO tb_product(name,description,price) values ('AMERICAN BURGUER','A DELICIOUS SANDWICH WITH LOTS OF SPICE AND LOVE',10.00);
INSERT INTO tb_product(name,description,price) values ('TOFU SANDWICH','A DELICIOUS AND NATURAL SANDWICH WITH LOTS OF LOVE',15.00);
INSERT INTO tb_product(name,description,price) values ('COKE','A DELICIOUS COLD DRINK',2.00);
INSERT INTO tb_product(name,description,price) values ('BEER','A DELICIOUS BEER',3.00);
INSERT INTO tb_product(name,description,price) values ('REDBULL','A DRINK TO KEEP YOU AWAKE',4.00);
INSERT INTO tb_product(name,description,price) values ('ORANJE JUICE','A VERY TASTY AND NATURAL JUICE',1.50);
INSERT INTO tb_product_category(category_id,product_id) values (1,1);
INSERT INTO tb_product_category(category_id,product_id) values (1,2);
INSERT INTO tb_product_category(category_id,product_id) values (5,2);
INSERT INTO tb_product_category(category_id,product_id) values (5,7);
INSERT INTO tb_product_category(category_id,product_id) values (2,3);
INSERT INTO tb_product_category(category_id,product_id) values (2,4);
INSERT INTO tb_product_category(category_id,product_id) values (3,5);
INSERT INTO tb_product_category(category_id,product_id) values (3,6);
INSERT INTO tb_product_category(category_id,product_id) values (3,7);
INSERT INTO tb_product_category(category_id,product_id) values (4,8);
INSERT INTO tb_product_category(category_id,product_id) values (4,9);
INSERT INTO tb_product_category(category_id,product_id) values (4,10);
INSERT INTO tb_product_category(category_id,product_id) values (4,11);