-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdash1.sql
52 lines (41 loc) · 988 Bytes
/
dash1.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
CREATE TABLE meses (
id_mes int NOT NULL,
mes varchar(20) NOT NULL PRIMARY KEY
);
INSERT INTO meses (id_mes, mes) VALUES
(4, 'ABR'),
(11, 'NOV'),
(8, 'AGO'),
(12, 'DEZ'),
(9, 'SET'),
(2, 'FEV'),
(1, 'JAN'),
(7, 'JUL'),
(6, 'JUN'),
(5, 'MAI'),
(10, 'OUT'),
(3, 'MAR');
CREATE TABLE clientes (
id_cliente int NOT NULL AUTO_INCREMENT PRIMARY KEY,
mes_cliente varchar(10) NOT NULL,
quantidade int NOT NULL,
FOREIGN KEY (mes_cliente) REFERENCES meses(mes)
);
INSERT INTO clientes (mes_cliente, quantidade) VALUES
('JAN', 120),
('FEV', 160),
('MAR', 300);
CREATE TABLE vendas (
id_venda int AUTO_INCREMENT NOT NULL PRIMARY KEY,
mes_venda varchar(20) NOT NULL,
quantidade_venda int NOT NULL,
valor_venda float NOT NULL,
FOREIGN KEY (mes_venda) REFERENCES meses(mes)
);
INSERT INTO vendas (mes_venda, quantidade_venda, valor_venda) VALUES
('FEV', 98, 2155.02),
('JAN', 44, 967.56),
('JAN', 100, 2199),
('MAR', 5, 109.95),
('JAN', 18, 395.82),
('MAR', 2, 43.98);