-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
86 lines (72 loc) · 3.51 KB
/
Copy pathschema.sql
File metadata and controls
86 lines (72 loc) · 3.51 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
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
DROP TABLE IF EXISTS item_adicional, item_pedido, pedido, adicional, produto, ingrediente, funcionario CASCADE;
-- Tabela de ingredientes/ estoque
Create Table if not exists ingrediente(
id Serial Primary Key,
nome Varchar(100) not NULL,
quantidade Integer not NULL DEFAULT 0
);
--Tabela de produtos(sorvetes base)
Create Table if not exists produto(
id Serial Primary Key,
nome Varchar(100) not Null,
tipo Varchar(100) not NULL,
preco Numeric(10, 2) not Null
);
--tabela de extras/ adicionais
Create table if not exists adicional(
id serial primary key,
nome varchar(100) not null,
preco numeric(10, 2) not null
);
--tabela de funcionários
create table if not exists funcionario(
id serial primary key,
nome varchar(100) not null,
cargo varchar(50) not null
);
--tabela de pedidos
create table if not exists pedido(
id serial primary key,
status varchar(30) not null default 'ABERTO',
pagamento varchar(20),
total numeric(10,2),
criado_em timestamp not null default now()
);
create table if not exists item_pedido(
id serial primary key,
pedido_id integer not null references pedido(id),
produto_id integer not null references produto(id),
quantidade integer not null default 1,
preco_unit numeric(10, 2) not null
);
--tabela de extras
create table if not exists item_adicional (
id serial primary key,
item_pedido_id integer not null references item_pedido(id),
adicional_id integer not null references adicional(id)
);
-- Ingredientes do estoque
INSERT INTO ingrediente (nome, quantidade) VALUES
('Chocolate', 100),
('Morango', 100),
('Baunilha', 100),
('Granulado', 50),
('Calda', 50),
('Kit-Kat', 30),
('Frutas', 40);
-- Produtos base
INSERT INTO produto (nome, tipo, preco) VALUES
('Sorvete Casquinha', 'CASQUINHA', 5.00),
('Sorvete Copo Pequeno', 'COPO_PEQUENO', 8.00),
('Sorvete Copo Grande', 'COPO_GRANDE', 12.00);
-- Extras disponíveis
INSERT INTO adicional (nome, preco) VALUES
('Calda de Chocolate', 2.00),
('Granulado', 1.00),
('Kit-Kat', 3.00),
('Frutas', 2.50);
-- Funcionários
INSERT INTO funcionario (nome, cargo) VALUES
('Maria', 'Atendente'),
('João', 'Gerente');
ALTER TABLE pedido ADD COLUMN IF NOT EXISTS descricao TEXT DEFAULT '';