Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create database floricultura;
- use floricultura;
- create table clientes (
- cod_cliente int unsigned auto_increment,
- nome varchar(100) not null,
- dt_nasc date null,
- cpf char(11) not null,
- primary key (cod_cliente),
- unique index cpf_unique (cpf)
- );
- create table funcionarios (
- matricula int(8) zerofill,
- nome varchar(100) not null,
- dt_adms date not null,
- cargo varchar(30) not null,
- primary key (matricula)
- );
- create table categorias (
- cod_categoria int unsigned auto_increment,
- descricao varchar(100) not null,
- primary key (cod_categoria)
- );
- create table produtos (
- cod_produtos int unsigned auto_increment,
- cod_categoria int,
- descricao varchar(100) binary not null,
- vlr_unit decimal(10,2) not null,
- primary key (cod_produtos)
- );
- create table vendas (
- cod_venda int unsigned auto_increment,
- cod_funcionario int not null,
- cod_cliente int not null,
- vlr_total decimal(10,2) unsigned not null,
- data date not null,
- primary key (cod_venda)
- );
- create table itens_venda (
- cod_venda int not null,
- item int not null,
- cod_produto int not null,
- qtd int unsigned not null,
- vlr_unit decimal(10, 2) not null,
- vlr_pedido decimal(10,2) GENERATED ALWAYS AS ((vlr_unit*qtd)) STORED,
- primary key (item, cod_venda)
- );
- insert into clientes (nome, dt_nasc, cpf) values
- ("Arthur Felix", "2003-11-10", "07725082913"),
- ("Gustavo Nunes", "2002-11-09", "07893820139");
- insert into funcionarios (matricula, nome, dt_adms, cargo) values
- ("84923", "Pedro Moratelli", "2018-08-10", "Vendedor"),
- ("019123", "Thiago SobrenomeDificil", "2019-10-10", "Gerente");
- insert into vendas (cod_funcionario, cod_cliente, vlr_total, data) values
- (1, 2, 45, "2019-10-15"),
- (2, 1, 29, "2019-05-10");
- insert into produtos values
- (null, 1, "Orquideas", 15.00),
- (null, 1, "Muda de Arvores", 25.00),
- (null, 2, "Vaso", 20.00),
- (null, 2, "Pa", 10.00),
- (null, 2, "Adubo", 8.00),
- (null, 3, "Cesto", 5.00),
- (null, 3, "Inseticida", 12.00);
- insert into categorias values
- (null, "Plantas"),
- (null, "Jardinagem"),
- (null, "Outros");
- insert into itens_venda (cod_venda, item, cod_produto, qtd, vlr_unit) values
- (1, 1, 1, 1, 15.00),
- (1, 2, 3, 1, 20.00),
- (1, 3, 4, 1, 10.00),
- (2, 1, 6, 1, 5.00),
- (2, 2, 7, 2, 12.00);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement