Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE SCHEMA IchibaSuperMarket;
- USE IchibaSuperMarket;
- -- TABELA DE CURSOS xxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE curso (
- id char(4),
- cargahoraria integer(4) not null CHECK ( cargahoraria > 0 ),
- descricao varchar(40),
- primary key(id)
- );
- -- inserindo valores para curso OK
- INSERT INTO curso VALUES
- ( '7070', 12 , 'entregas'),
- ( '1010' , 20, 'libras'),
- ( '2276' , 5 , 'marketing'),
- ( '9085' , 13 , 'informatica'),
- ( '7324' , 7 , 'financas'),
- ( '8012' , 60 , 'ingles'),
- ( '3390', 30 , 'relacoes humanas'),
- ( '8344' , 30 , 'estatistica'),
- ( '5793' , 40 , 'circuitos'),
- ( '3333' , 20 , 'ginastica laboral'),
- ( '5449', 40 , 'mecanica'),
- ( '7573' , 20, 'administracao'),
- ( '9090' , 40 , 'programacao'),
- ( '2101' , 40 , 'espanhol');
- -- TABELA DE JORNADA DE TRABALHO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE jornadatrabalho (
- id char(4) ,
- descricao varchar(60),
- trabalha_sabado boolean not null default true,
- primary key(id)
- );
- -- inserindo valores na tabela jornadatrabalho OK
- INSERT INTO jornadatrabalho ( id , descricao , trabalha_sabado) VALUES
- ('0001' , 'segunda a domingo' , true),
- ('0002' , NULL , false),
- ('0003' , 'trabalha feriados' , true),
- ('0004' , ' ' , true ),
- ('0005' , ' ' , false),
- ('0006' , ' ', false),
- ('0007' , 'trabalha feriados' , true),
- ('0008' , ' ' , true),
- ('0009' , ' ' , true),
- ('0010' , ' ', true ),
- ('0011' , ' ', true),
- ('0012', ' ', true),
- ('0013' , ' ' , true),
- ('0014', ' ' , true),
- ('0015' , ' ', true ),
- ('0016' , ' ' , false);
- -- TABELA DE TURNO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE turno (
- cod char(4),
- descricao varchar(60),
- hora_inicio time not null,
- hora_fim time not null,
- primary key (cod)
- );
- -- inserindo valores na tabela de turno OK
- INSERT INTO turno ( cod, descricao , hora_inicio, hora_fim ) VALUES
- ('0001' , ' ' , '07:30:00' , '16:30:00'),
- ('0002' , ' ', '08:40:00' , '17:40:00'),
- ('0003' , ' ' , '07:00:00' , '14:00:00'),
- ('0004' , ' ' , '11:00:00' , '17:00:00'),
- ('0005' , ' ' , '14:00:00' , '18:30:00'),
- ('0006' , ' ' , '13:35:00' , '19:45:00'),
- ('0007' , ' ' , '07:30:00' , '12:30:00'),
- ('0008' , ' ' , '07:10:00' , '13:30:00'),
- ('0009' , ' ' , '18:00:00' , '23:55:00'),
- ('0010' , ' ' , '00:00:01' , '08:00:01');
- -- TABELA DE DIA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE dia (
- sequencial char(4),
- descricao varchar(60),
- primary key (sequencial)
- );
- -- inserindo valores na tabela de dia OK
- INSERT INTO dia ( sequencial , descricao ) VALUES
- ('0001' , ' segunda-feira' ),
- ('0002' , ' terça-feira' ),
- ('0003' , ' quarta-feira' ),
- ('0004' , ' quinta-feira' ),
- ('0005' , ' sexta-feira' ),
- ('0006' , ' sabado' ),
- ('0007' , ' domingo' );
- -- TABELA DA MATRIZ xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE matriz (
- CNPJ char(14),
- nomefantasia varchar(10) not null,
- primary key (CNPJ)
- );
- -- inserindo valores na tabela Matriz OK
- INSERT INTO matriz( CNPJ , nomefantasia ) VALUES
- ( '23416393000114' , 'SUPER'),
- ( '23416393000140' , 'ICBPE'),
- ( '23416393000169' , 'ICBRJ'),
- ( '76166587000175' , 'FRUFRU'),
- ( '33353657000191' , 'BILU'),
- ( '01545535000100' , 'MILU' );
- -- TABELA DE TELEFONE DA MATRIZ xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE telefone_matriz (
- seq char(4),
- CNPJ char(14),
- telefone char(10),
- primary key (seq),
- CONSTRAINT fk_cnpjmatriz foreign key (CNPJ) references matriz (CNPJ) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela telefone_matriz OK
- INSERT INTO telefone_matriz (seq , CNPJ , telefone ) VALUES
- ('0001' , '23416393000114' , '8133002432'),
- ('0002 ', '23416393000140' , '8133002149'),
- ('0003' , '23416393000140' , '1133002932'),
- ('0004' , '23416393000140' , '1140443949'),
- ('0005' , '23416393000169' , '1433004732'),
- ( '0006' ,'23416393000169' , '1440002449');
- -- TABELA DE FILIAL xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE filial (
- seq char(4),
- CNPJ_Matriz char(14),
- CPF_gerente char(11) ,
- endereco varchar(50),
- qtd_func int(4) CHECK (qtd_func >= 0),
- primary key ( seq ),
- CONSTRAINT fk_cnpjmatrizfilial foreign key ( CNPJ_MATRIZ ) references matriz (CNPJ) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela filial OK
- INSERT INTO filial ( seq , CNPJ_Matriz , CPF_gerente , endereco , qtd_func ) VALUES
- ( '0001' , '23416393000114' , NULL , 'Rua valtavares ' , 4 ),
- ( '0002' , '23416393000114' , NULL , 'Rua alivetania ' , 4 ),
- ( '0003' , '23416393000140' , NULL, 'Rua maranguape ' , 4 ),
- ( '0004' , '23416393000169' , NULL , 'Rua fernigan ' , 4 );
- -- TABELA DE TELEFONE DA FILIAL xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE telefone_filial (
- seq_filial char(4),
- CNPJ_Matriz char(14),
- telefone char(10),
- CONSTRAINT telefone_filial_pk primary key (seq_filial , CNPJ_Matriz , telefone ),
- CONSTRAINT fk_seq foreign key (CNPJ_Matriz) references filial (CNPJ_Matriz) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT fk_cnpj foreign key (seq_filial) references filial (seq) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela telefone_filial OK
- INSERT INTO telefone_filial( seq_filial , CNPJ_Matriz , telefone ) VALUES
- ( '0001' , '23416393000114' , '1133115021' ),
- ( '0002' , '23416393000114' , '1133505231' ),
- ( '0003' , '23416393000140' , '8143022151' ),
- ( '0004' , '23416393000169' , '1431205412' );
- -- TABELA DE FUNCIONARIOS INCOMPLETA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 1
- # --------------------------------ALTERANDO --------------------------------
- CREATE TABLE funcionario (
- CPF char(11) ,
- id_jornada char(4) , # NAO TEM RELACIONAMENTO OBRIG , TIREI O NOT NULL
- seq_filial char(4),
- cnpj_matriz char(14) not null,
- data_admissao date,
- sex enum ('M', 'F'),
- estado_civil varchar(10),
- login varchar(60) default 'func' ,
- senha varchar(15) default 'func',
- RG char(7) not null UNIQUE,
- nome varchar(45),
- situacao varchar(10) ,
- endereco varchar(45),
- primary key(CPF),
- foreign key (id_jornada) references jornadatrabalho (id) ,
- foreign key ( seq_filial ) references filial (seq),
- foreign key (cnpj_matriz) references matriz (CNPJ)
- );
- -- inserindo valores para funcionario OK
- INSERT INTO funcionario (CPF, id_jornada, seq_filial, cnpj_matriz, data_admissao, sex, estado_civil, login, senha, RG, nome, situacao, endereco) VALUES
- ('77491222226' , '0001', '0001' , '23416393000114' , '2005-04-12' , 'F', 'solteiro' , 'helo.12' , '123' , '1259312' , 'Heloisa Macedo de Souza' , 'ativo' , 'Rua Eloy Monteiro Nunes'),
- ('98243208909' , '0002' , '0001' ,'23416393000114' , '2007-07-25' , 'M' , 'casado' , 'Garza2019' , 'E3221' ,'3654296' , 'Elias ChateauBriand Gomes' , 'inativo' , 'Avenida Paraíba'),
- ('57325297050' , '0003' , '0003' , '23416393000140', '2003-09-02', 'F', 'viuva' , 'Riggs642' , 'YM' , '4563573' , 'Maria Helena Rosendo' , 'ativo', 'Rua Pedro Viana Neto'),
- ('16565525749' , '0004' , '0002' , '23416393000114' , '2000-01-07', 'F', 'solteiro' , 'Eugene759' , 'XX133','2144770', 'Afrodite Bezerra das Flores' , 'ativo', 'Rua Amelia'),
- ('57859332507', '0005' , '0002' , '23416393000114' , '2006-02-02' , 'M' , 'solteiro' , 'TM1' , '98UJ' , '1555582' , 'Mauricio de Souza Carvalho' , 'ativo' , ' Rua da Concordia'),
- ('96202875763' , '0006' , '0003' , '23416393000140' , '2001-09-11' , 'F' , 'solteiro' ,'Juli.Alves', '8900','3494135' , 'Juliana Macedo Pinheiro' , 'inativo' , 'Rua Tucano'),
- ('02123011878' , '0007' , '0004' , '23416393000169' , '2000-08-10' , 'M' , 'solteiro' , 'ana.mari' , 'bb34','1783833' , 'Mariana Siqueira Jardim' , 'ativo' , 'Rua Lealberto Leal'),
- ('15141182894' , '0008' , '0001' , '23416393000114' , '2005-06-13' , 'F' , 'casado' , 'dudu.arda' , '1999' ,'2267700', 'Bernadete Maria da Silva' , 'ativo' , 'Rua Guajuvira'),
- ('33666472214' , '0009' , '0004' , '23416393000169' , '2011-03-01' , 'F' , 'solteiro', 'ana.belle' , 'AX6', '4137799','Anabelle Cristina Leal de Figueiredo' , 'ativo', 'Rua Manuel de Medeiros'),
- ('32568071001', '0010' , '0001' , '23416393000114' , '2010-09-26' , 'F' , 'casado' , 'bee.a' , '134N' , '4163131', 'Ana Beatriz Castanho Guedes' , 'ativo', 'Rua Jornalista Benedito Cunha'),
- ('45321186898' , '0011', '0004', '23416393000169' , '2007-09-20', 'M' , 'solteiro' , 'alan.marq' , '0j7e','1557345','Allan Jose Malta de Souza' , 'inativo', ' Rua Projetada'),
- ('86147207504' , '0012' , '0004' , '23416393000169' , '2001-10-27' , 'F' , 'casado' , 'lelezinha' , '223d' ,'3217467', 'Leticia Santana Rodrigues' , 'ativo' , 'Rua Felipe Guerra'),
- ('85902755239' , '0013' , '0003' , '23416393000140' , '2005-11-14' , 'F' , 'solteiro' , 'mwd2', '1332', '2437550', 'Gabriela Amado Batista', 'ativo', 'Rua da Palma'),
- ('14073416260' , '0014' , '0002' , '23416393000114', '2000-02-14', 'M' , 'casado', 'mumu321', '9901', '1190089','Jadiane Matoso dos Santos', 'ativo', 'Rua Real da Torre'),
- ('32970753502', '0015' , '0002' , '23416393000114' , '2013-01-10', 'F' , 'solteiro' , 'JH10' , '1132' , '2422874', 'Viviane Mendonca do Nascimento', 'ativo', 'Rua da Harmonia'),
- ('88356795591' , '0016' , '0003' , '23416393000140' , '2012-06-10', 'M' , 'casado', '991jj', '1233', '1316411', 'Ronaldo Fagundes da Silva' , 'ativo', 'Rua da Praia');
- -- TABELA DE ESTOQUISTA HERDA FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- # ------------- ALTERANDO VALORES ------------------
- CREATE TABLE estoquista (
- CPF char(11), -- REMOVI O SEQ E COLOQUEI O CPF COMO FK
- CONSTRAINT estoquista_pk primary key (CPF),
- CONSTRAINT fk_estoq foreign key (CPF) references funcionario(CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores para estoquista OK
- INSERT INTO estoquista (CPF) VALUES
- ('77491222226'),
- ('98243208909'),
- ('57859332507'),
- ('16565525749');
- -- TABELA DE DBA HERDA FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- # ------------- ALTERANDO VALORES ------------------
- CREATE TABLE DBA (
- CPF char(11), # REMOVI O SEQ E COLOQUEI A PK COMO CPF
- CONSTRAINT DBA_pk primary key (CPF),
- CONSTRAINT fk_dba foreign key(CPF) references funcionario(CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores para dba OK
- INSERT INTO DBA (CPF) VALUES
- ('45321186898');
- -- TABELA DE GERENTE HERDA FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- # ------------- ALTERANDO VALORES ---------------
- CREATE TABLE gerente(
- CPF char(11), # TIREI O SEQ E COLOQUEI O CPF COMO PK
- CONSTRAINT gerente_pk primary key (CPF),
- CONSTRAINT fk_gerente foreign key(CPF) references funcionario(CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores para gerente OK
- INSERT INTO gerente (CPF) VALUES
- ('96202875763'),
- ('02123011878'),
- ('15141182894'),
- ('57325297050');
- -- TABELA DE ENTREGADOR HERDA FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE entregador(
- CPF char(11),
- CONSTRAINT entregador_pk primary key (CPF),
- CONSTRAINT fk_entregador foreign key(CPF) references funcionario(CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela entregador OK
- INSERT INTO entregador (CPF) VALUES
- ( '33666472214'),
- ('86147207504'),
- ('32970753502'),
- ('32568071001');
- -- TABELA DE SUPERVISOR ESTOQUE HERDA FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- # --------------------ALTERANDO VALORES-----------------------
- CREATE TABLE supervisorestoque (
- CPF char(11), # REMOVI SEQ E COLOQUEI O CPF COMO PK
- CONSTRAINT supervisorestoque_pk primary key(seq),
- CONSTRAINT fk_super foreign key(CPF) references funcionario(CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valotes na tabela supervisorestoque OK
- INSERT INTO supervisorestoque (CPF) VALUES
- ('14073416260'),
- ('85902755239' ),
- ('88356795591');
- -- TABELA MULTVALORADA DE FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- #---------------------ALTERANDO VALORES ------------------
- CREATE TABLE telefone_funcionario(
- CPF char(11), # REMOVI O SEQ E COLOQUEI A CHAVE COMPOSTA
- telefone char(11),
- CONSTRAINT telefone_funcionario_pk primary key (CPF, telefone),
- CONSTRAINT fk_telefonefuncinario foreign key(CPF) references funcionario(CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela de telefone_funcionario OK
- INSERT INTO telefone_funcionario ( CPF, telefone ) VALUES
- ('14073416260' , '08133552321'),
- ('85902755239' , '08132324567'),
- ('88356795591', '08131311111'),
- ('32568071001', '08134587831'),
- ('32970753502', '08132324502'),
- ('32970753502' , '08191912343'),
- ('33666472214' , '08199096532'),
- ('86147207504', '08132732100'),
- ('96202875763' , '08199690359');
- -- alterando a tabela filial
- ALTER TABLE filial add constraint foreign key ( CPF_gerente ) references gerente (CPF); -- createdyes 13
- -- TABELA DE NOTIFICAÇÃO DADA A FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE notificacao (
- id char(4),
- cpf_fun char(11) not null,
- dia date not null,
- descricao varchar(80),
- CONSTRAINT notificacaco_pk primary key (id),
- CONSTRAINT notificacao_cpf_fun_fk foreign key (Cpf_fun) references funcionario (CPF)
- );
- -- inserindo valores na tabela de notificacao OK
- INSERT INTO notificacao (id, cpf_fun, dia, descricao) VALUES
- ('2940' , '33666472214' , '2014-02-26' , NULL), -- ENTREGADOR
- ('2941' , '86147207504' , '2015-03-06' , NULL), -- ENTREGADOR
- ('2942' , '32970753502' , '2015-06-02' , NULL), -- ENTREGADOR
- ('2943' , '33666472214' , '2014-07-20' , NULL),
- ('2944' , '33666472214' , '2014-07-20' , NULL),
- ('2945' , '16565525749' , '2014-02-12' , NULL),
- ('2946' , '33666472214' , '2015-03-06' , NULL),
- ('2947' , '33666472214' , '2015-06-02' , NULL),
- ('2948' , '77491222226' , '2014-07-20' , NULL),
- ('2949' , '88356795591' , '2014-07-20' , NULL),
- ('2950' , '45321186898' , '2014-07-20' , NULL),
- ('2951' , '86147207504' , '2014-02-10' , NULL);
- -- TABELA DE NOTIFICAÇÃO DE MULTA DADA A FUNCIONARIO HERDA DE NOTIFICAÇÃO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx
- -- createdyes 13
- # ---------------------ALTERANDO VALORES ---------------------
- CREATE TABLE notif_multa (
- id char(4), # REMOVI SEQ E DEIXEI ID COMO PK
- pontos_cnh int,
- valor float not null,
- cep char(8),
- complemento varchar(30),
- CONSTRAINT notif_multa_pk primary key(id),
- CONSTRAINT fk_notmulta foreign key (id) references notificacao(id) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo dados para notif_multa OK
- INSERT INTO notif_multa (id , pontos_cnh, valor, cep, complemento) VALUES
- ('2940', 3 , 58.50 , 50789123 , 'Rua da Aurora'),
- ('2941' ,4 , 198.50 , 54330315 , 'Rua Itacuruba'),
- ('2942' , 5 , 398.50 , 54315330 , 'Rua verdejantes');
- -- TABELA DE NOTIFICAÇÃO ADVERTENCIA DADA A FUNCIONARIO HERDA DE NOTIFICAÇÃO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx
- -- createdyes 13
- CREATE TABLE notif_advertencia (
- id char(4),
- descricao varchar(20),
- CONSTRAINT notif_advertencia_pk primary key(id),
- CONSTRAINT fk_notadvert foreign key (id) references notificacao (id) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo dados para notif_advertencia OK
- INSERT INTO notif_advertencia (id, descricao ) VALUES
- ('2943' , NULL),
- ('2944' , NULL),
- ('2945' , NULL);
- -- TABELA DE NOTIFICAÇÃO DE SUSPENSAO DADA A FUNCIONARIO HERDA DE NOTIFICAÇÃO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx
- -- createdyes 13
- CREATE TABLE notif_suspensao (
- id char(4),
- data_inicio date not null,
- data_termino date not null,
- CONSTRAINT notif_suspensao_pk primary key(id),
- CONSTRAINT not_suspen foreign key (id) references notificacao(id) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inseindo dados para notif_suspensao OK
- INSERT INTO notif_suspensao ( id , data_inicio , data_termino ) VALUES
- ('2946' , '2015-06-02' , '2015-06-04' ),
- ('2947' , '2015-08-20' , '2015-08-23' ),
- ('2948' , '2015-09-10' , '2015-09-13' );
- -- TABELA DE NOTIFICAÇÃO DE FALTA DADA A FUNCIONARIO HERDA DE NOTIFICAÇÃO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx
- -- createdyes 13
- CREATE TABLE notif_falta (
- id char(4),
- dia date,
- duracao int CHECK (duracao > 0 ),
- CONSTRAINT notif_falta_pk primary key (id),
- CONSTRAINT fk_notfalta foreign key (id) references notificacao (id) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores para notif_falta OK
- INSERT INTO notif_falta ( id , dia , duracao ) VALUES
- ('2949' , '2015-06-01' , 3),
- ('2950' , '2015-08-19' , 2 ),
- ('2951' , '2015-09-09' , 2);
- -- TABELA DE FERIAS DE FUNCIONARIO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE ferias (
- id char(4),
- cpf_fun char(11) not null,
- numero_dias int not null,
- seq char(4) not null,
- data_inicio date not null,
- data_fim date not null,
- primary key (id),
- foreign key (cpf_fun) references funcionario (CPF)
- );
- -- insenrindo valores na tabela ferias OK
- INSERT INTO ferias (id , cpf_fun , numero_dias , seq , data_inicio , data_fim) VALUES
- ( '2340' , '96202875763' , 20 , '0001' , '2016-06-02' , '2016-06-22' ),
- ( '2341' , '32970753502' , 20 , '0002' , '2016-06-02' , '2016-06-22' ),
- ( '2342' , '45321186898' , 20 , '0003' , '2016-01-02' , '2016-01-22' ),
- ( '2343' , '57859332507' , 20 , '0004' , '2016-01-02' , '2016-01-22' ),
- ( '2344' , '14073416260' , 20 , '0005' , '2016-04-02' , '2016-04-22' );
- -- TABELA DE CONTRA CHEQUE xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE contracheque (
- seq char(4),
- mes_referencia char(2) CHECK( mes_referencia > 0 AND mes_referencia < 13 ),
- CPF char(11) not null,
- data_pagamento date not null,
- valor_bruto float(5) not null,
- valor_liqd float(5) not null,
- valor_desconto float(5),
- primary key (seq),
- foreign key(CPF) references funcionario(CPF)
- );
- -- inserindo valores na tabela contracheque OK
- INSERT INTO contracheque (seq ,mes_referencia , CPF, data_pagamento , valor_bruto, valor_liqd, valor_desconto) VALUES
- ('0001' ,'02', '96202875763' , '2017-02-15', 3250.30, 3237.68 , 12.32),
- ('0002' , '03' , '96202875763', '2017-03-15' , 3250.30, 3237.68, 12.32),
- ('0003', '05' , '45321186898' , '2017-05-15' , 8720.55,8708.8, 11.75),
- ('0004','01' , '57325297050' , '2017-01-15' , 5956.00, 5942.00 , 14.00),
- ('0005','03' , '85902755239' ,'2017-03-15', 4567.32 , 4553.32 , 14.00),
- ('0006','08' , '85902755239' , '2017-08-15',4567.32 , 4553.32 , 14.00),
- ('0007','01', '96202875763' , '2017-01-15', 3250.30, 3237.68 , 12.32),
- ('0008','11' , '45321186898' , '2017-11-15' , 8720.55,8708.8, 11.75),
- ('0009','07' , '45321186898' , '2017-07-15' , 8720.55,8708.8, 11.75),
- ('0010','04' , '45321186898' , '2017-04-15' , 8720.55,8708.8, 11.75),
- ('0011','04' , '02123011878' , '2017-04-15' ,4567.32 , 4553.32, 14.00),
- ('0012','05' ,'86147207504', '2016-05-16' , 3250.30, 3237.68 , 12.32);
- -- TABELA DE ENTREGA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE entrega (
- seq char(4) ,
- CPF_entregador char(11) not null,
- data_entrega date,
- hora_estimada time,
- primary key (seq),
- foreign key(CPF_entregador) references entregador(CPF)
- );
- -- inserindo valores na tabela de entrega OK
- INSERT INTO entrega ( seq , CPF_entregador , data_entrega , hora_estimada ) VALUES
- ('0001' , '33666472214' , '2016-04-09 ' , '07:30:00'),
- ('0002' , '33666472214' , '2016-04-09 ' , '19:45:00'),
- ('0003' , '33666472214' , '2016-04-09 ' , '18:00:00'),
- ('0004' , '33666472214' , '2016-04-09 ' , '09:30:00'),
- ('0005' , '33666472214' , '2016-04-09 ' , '13:30:00'),
- ('0006' , '86147207504' , '2016-04-02 ' , '06:30:00'),
- ('0007' , '86147207504' , '2016-04-02 ' , '11:45:00'),
- ('0008' , '86147207504' , '2016-04-02 ' , '14:00:00'),
- ('0009' , '86147207504' , '2016-04-02 ' , '015:30:00'),
- ('0010' , '86147207504' , '2016-04-02 ' , '14:30:00');
- -- TABELA DE COMPRA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE compra (
- cod char(4),
- seq_entrega char(4) not null,
- valor_total float not null CHECK( valor_total > 0 ),
- dia date not null,
- valor_total_desconto float CHECK (valor_total_desconto >= 0 ),
- statos boolean default true,
- primary key (cod),
- foreign key (seq_entrega) references entrega ( seq )
- );
- -- inserindo valores na tabela de compra OK
- INSERT INTO compra ( cod , seq_entrega , valor_total , dia , valor_total_desconto , statos ) VALUES
- ('0001' , '0001 ' , 693 , '2016-04-09 ' , 0 , true ),
- ('0002' , '0002 ' , 789 , '2016-04-09 ' , 23.4 , true ),
- ('0003' , '0003 ' , 403 , '2016-04-09 ' , 4.2 , true ),
- ('0004' , '0004 ' , 233 , '2016-04-09 ' , 0 , true ),
- ('0005' , '0005 ' , 70 , '2016-04-09 ' , 0 , true ),
- ('0006' , '0006 ' , 2020 , '2016-04-02 ' , 20.2 , true ),
- ('0007' , '0007 ' , 400 , '2016-04-02 ' , 0 , true ),
- ('0008' , '0008 ' , 121 , '2016-04-02 ' , 0 , true ),
- ('0009' , '0009 ' , 133 , '2016-04-02 ' , 3.2 , true ),
- ('0010' , '0010 ' , 154 , '2016-04-02 ' , 0 , true );
- -- TABELA DE COMPRA COMUM xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE compra_comum (
- seq char(4),
- cod char(4),
- primary key(seq),
- CONSTRAINT fk_compracomum foreign key (cod) references compra (cod) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela de compra comum OK
- INSERT INTO compra_comum (seq , cod ) VALUES
- ('0001','0001'),
- ('0002' ,'0003'),
- ('0003', '0005'),
- ('0004' ,'0006'),
- ('0005' ,'0008');
- -- TABELA DE COMPRA PROGRAMADA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE compra_programada (
- seq char(4),
- cod char(4),
- data_1 date not null,
- data2 date not null,
- esta_ativa boolean default true,
- primary key (seq),
- CONSTRAINT fk_compraprogramada foreign key (cod) references compra (cod) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela de compra programada
- INSERT INTO compra_programada ( seq ,cod , date_1 , date2 , esta_ativa ) VALUES
- ('0001' ,'0002' , '2016-04-09' , '2017-04-09' , true ),
- ('0002' , '0004' , '2016-04-09' , '2017-01-09' , true ),
- ('0003' , '0007' , '2016-04-02' , '2016-11-02' , true ),
- ('0004' ,'0009' , '2016-04-02' , '2017-02-02' , true ),
- ('0005' , '0010' , '2016-04-02' , '2017-04-02' , true );
- -- TABELA ITEM DE COMPRA createdyes 13
- CREATE TABLE item_compra (
- seq char(4),
- cod_compra char(4) not null,
- cod_produto char(4) not null,
- quantidade int CHECK (quantidade > 0) ,
- valor_desconto float default 0 CHECK (valor_desconto >= 0),
- valor_unitario float CHECK (valor_unitario > 0),
- primary key (seq),
- foreign key (cod_compra) references compra (cod),
- foreign key (cod_produto) references produto_ref (cod)
- );
- -- ITEM COMPRA INCOMPLETO
- #INSERT INTO item_compra ( seq , cod_compra , cod_produto , quantidade , valor_desconto , valor_unitario ) VALUES
- #('0001' , '0001' ,
- -- TABELA DE GARAGEM xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE garagem (
- cod char(4),
- seq_filial char(4) not null ,
- CNPJ_matriz char(14) not null,
- descricao varchar(15),
- capacidade int(3) not null,
- num_veiculos_atual int(3),
- primary key(cod),
- foreign key(seq_filial ) references filial (seq),
- foreign key (CNPJ_matriz) references filial(CNPJ_matriz)
- );
- -- inserindo valores na tabela garagem OK
- INSERT INTO garagem ( cod , seq_filial , CNPJ_matriz , descricao , capacidade , num_veiculos_atual ) VALUES
- ( '0001' , '0001' , '23416393000114' , null , 4 , 2 ),
- ( '0002' , '0002' , '23416393000114' , null , 4 , 2 ),
- ( '0003' , '0003' , '23416393000140' , null , 4 , 2 ),
- ( '0004' , '0004' , '23416393000169' , null , 4 , 2 );
- -- TABELA DE VEICULO xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE veiculo (
- placa char(7),
- seq_filial char(4) not null,
- CNPJ_matriz char(14) not null,
- cod_garagem char(4) not null,
- modelo varchar(15),
- descricao varchar(15),
- cor varchar(10),
- ano year,
- statuss boolean default true,
- primary key (placa),
- foreign key(seq_filial ) references filial(seq) ,
- foreign key (CNPJ_matriz) references filial(CNPJ_Matriz),
- foreign key(cod_garagem) references garagem (cod)
- );
- -- inserindo valores na tabela veiculo OK
- INSERT INTO veiculo ( placa , seq_filial , CNPJ_matriz , cod_garagem , modelo , descricao , cor , ano , statuss ) VALUES
- ( 'PEX0220 ' , '0001' , '23416393000114' , '0001' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true),
- ( 'PEX2030 ' , '0001' , '23416393000114' , '0001' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true),
- ( 'VET4320 ' , '0002' , '23416393000114' , '0002' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true),
- ( 'VET3240 ' , '0002' , '23416393000114' , '0002' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true),
- ( 'WCV0943' , '0003' , '23416393000114' , '0003' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true),
- ( 'WCV3344 ' , '0003' , '23416393000114' , '0003' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true),
- ( 'HLT0032 ' , '0004' , '23416393000114' , '0004' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true),
- ( 'HLT3994 ' , '0004' , '23416393000114' , '0004' , 'Caminhão' , 'Mercedes-benz' , 'preto' , '2014' , true);
- -- TABELA DE ESTOQUE xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE estoque (
- id char(4),
- seq_filial char(7) not null,
- cnpj_matriz char(14) not null,
- descricao varchar(80),
- dt_ultima_entrada date,
- primary key (id),
- foreign key (seq_filial) references filial (seq),
- foreign key (cnpj_matriz) references filial(CNPJ_Matriz)
- );
- -- inserindo valores na tabela estoque OK
- INSERT INTO estoque ( id , seq_filial , cnpj_matriz , descricao , dt_ultima_entrada ) VALUES
- ( '0001' , '0001' , '23416393000114' , null , '2018-01-04'),
- ( '0002' , '0002' , '23416393000114' , null , '2018-01-04'),
- ( '0003' , '0003' , '23416393000140' , null , '2018-01-04'),
- ( '0004' , '0004' , '23416393000169' , null , '2018-01-04');
- -- TABELA MAQUINA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE maquina (
- id char(4),
- id_estoque char(4) not null,
- id_operador char(11) not null,
- ano year ,
- combustivel varchar(30),
- modelo varchar(30),
- capacidade float , -- CAPACIDADE EM KG
- elevavao_max float , -- ELEVAVAO EM METROS
- garantia date,
- tipo varchar(30),
- comprimento float , -- COMPRIMENTO EM METROS
- primary key (id),
- foreign key (id_estoque) references estoque (id),
- foreign key (id_operador) references estoquista (cpf)
- );
- -- inserindo valores na tabela maquina OK
- INSERT INTO maquina ( id , id_estoque , id_operador , ano, combustivel , modelo , capacidade , elevavao_max ,
- garantia , tipo , comprimento ) VALUES
- ( '0001' , '0001' , '77491222226' , '2014' , 'diesel', null , 600 , 5 , '2019-02-02' , 'empilhadeira' , 2.20 ),
- ( '0002' , '0002' , '57859332507' , '2014' , 'diesel', null , 600 , 5 , '2019-02-02' , 'empilhadeira' , 2.20 ),
- ( '0003' , '0003' , '16565525749' , '2014' , 'diesel', null , 600 , 5 , '2019-02-02' , 'empilhadeira' , 2.20 ),
- ( '0004' , '0004' , '98243208909' , '2014' , 'diesel', null , 600 , 5 , '2019-02-02' , 'empilhadeira' , 2.20 );
- -- TABELA DE AVARIA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE avaria (
- id char(4),
- causa varchar(20) not null,
- preco float(3) CHECK ( preco > 0 ),
- obs varchar(40),
- primary key(id)
- );
- -- inserindo valores na tabela avaria OK
- INSERT INTO avaria (id , causa , preco , obs ) VALUES
- ('0001' , 'Queda' , 30 , null ),
- ('0002' , 'Queda' , 10 , null ),
- ('0003' , 'Queda' , 200 , null ),
- ('0004' , 'Queda' , 32.2 , null ),
- ('0005' , 'Queda' , 230 , null ),
- ('0006' , 'Queda' , 92.2 , null );
- -- TABELA DE PRATELEIRA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE prateleira (
- codigo char(4),
- altura float(2) not null,
- comprimento float(2) not null,
- posicao_nivel char(2),
- primary key(codigo)
- );
- -- inserindo valores na tabela prateleira OK
- INSERT INTO prateleira ( codigo , altura , comprimento , posicao_nivel ) VALUES
- ('0001' , 5 , 10 , 'A1' ),
- ('0002' , 5 , 10 , 'A2' ),
- ('0003' , 5 , 10 , 'A3' ),
- ('0004' , 5 , 10 , 'A4' ),
- ('0005' , 5 , 10 , 'A5' ),
- ('0006' , 5 , 10 , 'B1' ),
- ('0007' , 5 , 10 , 'B2' ),
- ('0008' , 5 , 10 , 'B3' ),
- ('0009' , 5 , 10 , 'B4' ),
- ('0010' , 5 , 10 , 'B5' ),
- ('0011' , 5 , 10 , 'C1' ),
- ('0012' , 5 , 10 , 'C2' ),
- ('0013' , 5 , 10 , 'C3' ),
- ('0014' , 5 , 10 , 'C4' ),
- ('0015' , 5 , 10 , 'C5' );
- -- TABELA DE NCM DE PRODUTO createdyes 13
- CREATE TABLE NCM (
- id char(4),
- descricao varchar(40),
- cod_mercosul char(9) not null,
- primary key(id)
- );
- -- inserindo valores na tabela NCM OK
- INSERT INTO NCM ( id , descricao , cod_mercosul) VALUES
- ('0001', ' ' , '000000001'),
- ('0002' , ' ' , '000000002'),
- ('0003' , ' ', '000000003'),
- ('0004' , ' ', '000000004'),
- ('0005', ' ' , '000000005');
- -- TABELA DE UNIDADE DE PRODUTO createdyes 13
- CREATE TABLE unidade (
- cod char(4),
- descricao varchar(30),
- sigla char(2) not null,
- primary key(cod)
- );
- -- inserindo valores na tabela unidade OK
- INSERT INTO unidade (cod, descricao , sigla) VALUES
- ('0001', 'quilogramas', 'kg'),
- ('0002' , 'mililitros', 'mL'),
- ('0003', 'gramas' , 'g'),
- ('0004', 'litros' , 'L'),
- ('0005', 'miligramas' , 'mg');
- -- TABELA DE CATEGORIA DE PRODUTO createdyes 13
- CREATE TABLE categoria (
- cod char(4),
- descricao varchar(30) not null,
- primary key (cod)
- );
- -- inserindo valores na tabela categoria OK
- INSERT INTO categoria ( cod , descricao ) VALUES
- ('0001', 'Condimentos' ),
- ('0002' , 'Laticinios'),
- ('0003', 'HortiFruti'),
- ('0004' , 'Conservas'),
- ('0005', 'Limpeza'),
- ('0006' , 'Bebidas Alcoolicas'),
- ('0007' , 'Bebidas nao Alcoolicas'),
- ('0008' , 'Graos e Cereais');
- -- TABELA DE SUBCATEGORIA DE PRODUTO createdyes 13
- CREATE TABLE subcategoria (
- cod char(4),
- cod_categoria char(4) not null,
- descricao varchar(30) not null,
- primary key(cod),
- foreign key (cod_categoria) references categoria(cod)
- );
- -- inserindo valores na tabela subcategoria OK
- INSERT INTO subcategoria ( cod , cod_categoria , descricao ) VALUES
- ('0001' , '0001' , 'Vinagres'),
- ('0002' , '0001' , 'Temperos'),
- ('0003' , '0001' , 'Sal' ),
- ('0004' , '0001', 'Azeites'),
- ('0005' , '0001', 'Oleos'),
- ('0006' , '0001', 'Especiarias'),
- ('0007' , '0002', 'Leites'),
- ('0008' , '0002', 'Iogurtes'),
- ('0009' , '0002', 'Fermentados'),
- ('0010' , '0002', 'Queijos'),
- ('0011' , '0003', 'Ovos'),
- ('0012' , '0003', 'Frutas secas'),
- ('0013' , '0003', 'Legumes'),
- ('0014' , '0004' , 'Frutas'),
- ('0015' , '0004', 'Peixes'),
- ('0016' , '0004', 'Vegetais'),
- ('0017' , '0004', 'Cogumelos'),
- ('0018' , '0005', 'Detergente'),
- ('0019' , '0005', 'Desinfetante'),
- ('0020' , '0005', 'Sabao em po'),
- ('0021' , '0005', 'Sabao em barra'),
- ('0022' , '0005', 'Amaciante');
- -- TABELA DE MARCA DE PRODUTO createdyes 13
- CREATE TABLE marca (
- cod char(4),
- descricao varchar(40),
- primary key(cod)
- );
- -- inserindo valores na tabela marca OK
- INSERT INTO marca ( cod , descricao ) VALUES
- ('0001', 'Sadia'),
- ('0002' , 'Knorr'),
- ('0004' , 'Camponesa'),
- ('0005' , 'Kicaldo'),
- ('0006' , 'Vitarela'),
- ('0007' , 'Bauduco'),
- ('0008', 'OMO'),
- ('0009' , 'Dona Benta'),
- ('0010', 'Nestle');
- -- TABELA DE FORNECEDOR xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE fornecedor (
- cod char(4),
- nome varchar(20) not null,
- CNPJ char(14) not null,
- rua varchar(20),
- bairro varchar(15),
- CEP char(8),
- estado varchar(15) not null,
- ativo boolean default true,
- primary key(cod)
- );
- -- inserindo valores na tabela fornecedor OK
- INSERT INTO fornecedor ( cod , nome , CNPJ , rua , bairro , CEP , estado , ativo ) VALUES
- ('0001' , 'Sadia' , '55274471000180' , 'Rua valadares' , 'ipsep', '54330315' , 'Pernambuco' , true ) ,
- ('0002' , 'Pampers' , '26724671000180' , 'Rua cartomante' , 'ibura', '54202010' , 'Pernambuco' , true ) ,
- ('0003' , 'Vitarela' , '21712241000162' , 'Rua maniac' , 'algodão', '54215322' , 'São paulo' , true ) ,
- ('0004' , 'Coca-cola' , '26804531000180' , 'Rua argola' , 'vale tinhaem ', '51215020' , 'Rio de janeiro' , true ) ,
- ('0005' , 'Helmans' , '77411981000180' , 'Rua sartre' , 'gitacity ', '44650201' , 'São paulo' , true ),
- ('0006' , 'Bombril' , '53686527000188' , 'Rua 3' , 'Varzea' , '50980320' , 'Recife' , true );
- -- TABELA DE TELEFONE DE FORNECEDOR xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE telefone_fornecedor(
- seq char(4) ,
- cod_fornecedor char(4),
- telefone char(11),
- primary key(seq),
- CONSTRAINT fk_forn foreign key(cod_fornecedor) references fornecedor (cod) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela telefone_fornecedor OK
- INSERT INTO telefone_fornecedor ( seq , cod_fornecedor, telefone) VALUES
- ('0001' ,'0001' , '8133115544'),
- ('0002' ,'0002' , '8133468952'),
- ('0003' ,'0003' , '1140025632'),
- ('0004' ,'0004', '1432456895'),
- ('0005' , '0005', '1121452062');
- -- TABELA DE PRODUTO REF createdyes 13
- CREATE TABLE produto_ref (
- cod char(4),
- id_unidade char(4),
- id_marca char(4),
- id_ncm char(4),
- id_categoria char(4),
- id_subcategoria char(4),
- id_fornecedor char(4),
- qtd_estoque int ,
- ICMS float,
- CST char(3),
- preco_por_tabela float,
- cod_barra char(13) NULL,
- freq_pedido float NULL,
- descricao varchar(30),
- qtd_min int,
- qtd_total_estoque int,
- preco_ult_compra float,
- primary key (cod),
- foreign key (id_unidade) references unidade (cod),
- foreign key (id_marca) references marca (cod),
- foreign key (id_ncm) references ncm (id),
- foreign key (id_categoria) references categoria (cod),
- foreign key (id_subcategoria) references subcategoria (cod),
- foreign key (id_fornecedor) references fornecedor (cod)
- );
- -- INSERT INTO profuto_ref (cod, id_unidade , id_marca , id_ncm , id_categoria, id_subcategoria, id_fornecedor , qtd_estoque ,
- /* ICMS , CST , preco_por_tabela , cod_barra , freq_pedido , descricao , qtd_min, qtd_total_estoque , preco_ult_compra)
- */
- -- TABELA DE INCIDENTE xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE incidente (
- cod char(4),
- seq_entrega char(4) not null,
- dataa date not null,
- relatorio varchar(200),
- hora time not null,
- primary key(cod),
- foreign key ( seq_entrega) references entrega (seq)
- );
- -- inserindo valores na tabela incidente OK
- INSERT INTO incidente (cod , seq_entrega , dataa, relatorio , hora ) VALUES
- ('0001' , '0003' , '2016-04-09 ' , ' Tentativa de assalto ' , '18:06:00' ),
- ('0002' , '0005' , '2016-04-09 ' , ' Tentativa de assalto ' , '13:34:00' ),
- ('0003' , '0006' , '2016-04-02 ' , ' Tentativa de assalto ' , '06:32:00' );
- -- TABELA DOCS xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE docs (
- seq char(4),
- cod_incidente char(4),
- docs varchar(20),
- primary key (seq),
- CONSTRAINT fk_incidente foreign key (cod_incidente) references incidente (cod ) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela docs OK
- INSERT INTO docs ( seq , cod_incidente , docs ) VALUES
- ('0001' , '0001', null ) ,
- ('0002' ,'0002' , null ) ,
- ('0003' ,'0003' , null);
- -- TABELA DE TIPO DE PAGAMENTO createdyes 13
- CREATE TABLE tipo_pagamento (
- cod char(4),
- descricao varchar(30),
- primary key(cod)
- );
- -- inserindo valores na tabela tipo_pagamento OK
- INSERT INTO tipo_pagamento (cod, descricao ) VALUES
- ('0001' , 'Boleto Bancario'),
- ('0002' , 'Cartao de Credito'),
- ('0003' , 'Cartao de Debito');
- -- TABELA DE PEDIDO FORNECEDOR createdyes 13
- CREATE TABLE pedido_fornecedor (
- cod char(4),
- CPF_gerente char(11) not null,
- total_desconto float CHECK ( total_desconto >= 0 ),
- valor_total_IPI float CHECK ( valor_total_IPI >= 0 ),
- CFOP char(4) not null,
- valor_total float CHECK ( valor_total >= 0),
- dia date not null,
- statos boolean default true,
- valor_frete float CHECK (valor_frete >= 0),
- primary key (cod),
- foreign key (CPF_gerente) references gerente (CPF)
- );
- -- inserindo valores na tabela pedido_fornecedor OK
- INSERT INTO pedido_fornecedor ( cod, CPF_gerente , total_desconto , valor_total_IPI, CFOP, dia , statos, valor_frete ) VALUES
- ('0001' , '96202875763' , 12380.00, 354.20 , '0001', '2017-12-09' , true , 12.90),
- ('0002', '96202875763' , 3456.40 , 123.20 , '0002', '2017-11-09' , true , 10.30),
- ('0003' , '96202875763' , 2280.25 , 220.00,'0003', '2017-06-13', true , 28.50),
- ('0004' , '96202875763' , 12200.00, 123.99,'0004', '2017-07-04', true , 9.89),
- ('0005' , '96202875763' , 990.00 , 19.89, '0005', '2016-12-09', true , 12.43),
- ('0006' , '96202875763' , 5660.00, 56.70 , '0006', '2015-08-27' , true , 6.98),
- ('0007' , '96202875763' , 2890.00 , 35.47 , '0007', '2016-04-12' , true , 10.20),
- ('0008' , '96202875763' , 1873.20 , 190.00 ,'0008' , '2017-01-04' , true , 8.33),
- ('0009' , '96202875763' , 2348.80, 111.10 , '0009' ,'2017-06-09' , true , 10.22),
- ('0010' , '02123011878' , 1300.00, 132.30 , '0010','2017-08-27' , true , 11.30);
- -- TABELA DE FATURA xxxxxxxxxxxxxxxxxxxxxxxxDONExxxxxxxxxxxxxxxxxxxxx createdyes 13
- CREATE TABLE fatura (
- id char(4),
- cod_pedido_fornecedor char(4),
- data_vencimento date not null,
- valor_pago_atual float CHECK (valor_pago_atual > 0 ),
- valor_total_final float CHECK (valor_total_final > 0),
- data_emissao date not null,
- statos boolean default true,
- data_paga date,
- multa float,
- primary key (id),
- foreign key (cod_pedido_fornecedor) references pedido_fornecedor (cod)
- );
- -- inserindo valores na tabela fatura
- # INSERT INTO fatura ( id , cod_pedido_fornecedor , data_vencimento , valor_pago_atual, valor_total_final ,
- # data_emissao , statos , data_paga , multa )
- -- TABELA DE NOTA FISCAL createdyes 13
- CREATE TABLE nota_fiscal (
- NFE char(9),
- ICMS float not null,
- valor_total float not null CHECK ( valor_total > 0 ),
- valor_total_desconto float CHECK ( valor_total_desconto >= 0 ),
- dia date not null,
- valor_frete float,
- primary key (NFE)
- );
- -- inserindo valores na tabela nota_fiscal OK
- INSERT INTO nota_fiscal (NFE , ICMS , valor_total, valor_total_desconto, dia , valor_frete) VALUES
- ('111111109' , 0.04 , 143.98 , 139.90 , '2016-11-12' , 3.78),
- ('111111104' , 0.06 , 35.80 , 35.80, '2017-10-21' , 7.90),
- ('111111113' , 0.04 , 50.21 , 49.95 , '2012-03-27' , 10.32),
- ('111111105' , 0.06 , 173.98, 173.98 , '2010-06-13' , 8.50),
- ('111111107' , 0.02 , 50.43 , 50.43 , '2002-04-01' , 2.21),
- ('111111108' , 0.03 , 283.10 , 279.50 , '2011-11-11' , 4.30),
- ('111111139' , 0.02 , 123.54 , 111.20 , '2016-11-12' , 6.80),
- ('111111199' , 0.02 , 12.99 , 12.99 , '2016-11-13' , 8.30),
- ('111111129' , 0.03 , 346.10 , 336.10 , '2016-11-10' , 2.12);
- -- TABELA DE PAGAMENTO createdyes 13
- CREATE TABLE pagamento (
- cod char(4),
- id_fatura char(4) not null,
- cod_compra char(4) not null,
- cod_tipo_pagamento char(4) not null,
- valor_pago float CHECK ( valor_pago > 0 ),
- dia date not null,
- statos boolean default true ,
- tipo_pagamento enum ('Cartao credito', 'Cartao Debito', 'Boleto'),
- primary key (cod),
- foreign key (id_fatura) references fatura (id),
- foreign key (cod_compra) references compra (cod),
- foreign key (cod_tipo_pagamento) references tipo_pagamento ( cod)
- );
- -- INSERT INTO pagamento ( cod, id_fatura ,cod_compra , cod_tipo_pagamento , valor_pago , dia , statos, tipo_pagamento ) VALUES
- -- TABELA DA NOTA FISCAL FORNECEDOR createdyes 13
- CREATE TABLE nota_fiscal_fornecedor (
- NFE char(9),
- cod_pagamento char(4) not null,
- CFOP char(8) not null,
- IPI float,
- primary key(NFE),
- CONSTRAINT fk_ntfiscalfornecedor foreign key (NFE) references nota_fiscal (NFE) ON DELETE CASCADE ON UPDATE CASCADE,
- foreign key (cod_pagamento) references pagamento (cod)
- );
- -- NOTA FISCAL FORNEEDOR INCOMPLETO
- #INSERT INTO nota_fiscal_fornecedor (NFE, cod_pagamento , CFOP , IPI ) VALUES
- -- TABELA NOTA FISCAL COMPRA createdyes 13
- CREATE TABLE nota_fiscal_compra (
- NFE char(9),
- cod_pagamento char(4),
- primary key (NFE),
- CONSTRAINT fk_ntfiscalcompra foreign key (NFE) references nota_fiscal (NFE) ON DELETE CASCADE ON UPDATE CASCADE,
- foreign key (cod_pagamento) references pagamento (cod)
- );
- -- inserindo valores na tabela nota_fical_compra
- #INSERT INTO nota_fiscal_compra ( NFE , cod_pagamento ) VALUES
- #('111111129' ,
- -- TABELA DE CLIENTE createdyes 13
- CREATE TABLE cliente (
- CPF char(11),
- seq_filial char(4) not null,
- cnpj_matriz char(14) not null,
- cep char(8) not null,
- cidade varchar(30),
- numero char(11),
- descricao varchar(30),
- valor_credito float,
- p_nome varchar(20) not null,
- m_nome varchar(20) ,
- u_nome varchar(30) not null,
- rg char(7) not null,
- senha varchar(12) not null default '123456',
- tem_clube_desconto boolean default false,
- data_cadastro date,
- email varchar(40) not null,
- data_nascimento date not null,
- primary key (CPF),
- foreign key (seq_filial) references filial (seq ),
- foreign key (cnpj_matriz) references filial(CNPJ_Matriz)
- );
- -- !!!!!!!!!!!!!!!!!!!!!! FALTA INCLUIR O CNPJ NAS TUPLAS !!!!!!!!!!!!!!!!
- INSERT INTO cliente ( CPF , seq_filial , cnpj_matriz ,cep, cidade, numero, descricao , valor_credito, p_nome , m_nome , u_nome, rg , senha , tem_clube_desconto , data_cadastro , email , data_nascimento) VALUES
- ('54501233290' , '0001' , '23416393000114' , '52291045' , 'Recife' , '11111111111' , 'Rua Jaguaribara' , 1200.00 , 'Melissa' , 'Andreia' , 'Nascimento', '1908234', false , '2016-02-12', 'manasc@gmail.com' , '1999-06-13'),
- ('25251145314' , '0002' , '23416393000114', '50999321' , 'Olinda' , null, 'Rua de Saão Bento' , 0 , 'Marcos' , 'Andre' , 'Marques' , '9123786' , 'xxx9' , false , '2015-03-11' , 'marcossantos@hotmail.com' , '1980-03-25' ),
- ('13345509287' , '0001' , '23416393000114', '50348567' , 'Recife' , null , 'Rua Real da Torre ' , 0, 'Fatima' , 'Caixias' , 'Laffaiete' , '1866630' , '1233' , false , '2017-02-11' , 'falcaix@gmail.com' , '1972-09-09'),
- ('77658476358' , '0001' , '23416393000114', '63900435' , 'Ceará' , null , 'Rua Chile' , 0 , 'Renato' , 'Murilo' , 'Dias' , '1266839' , '34g4' , false , '2017-07-04', 'murilodias@gmail.com' , '1989-12-29'),
- ('50519774647' , '0002' , '23416393000114', '56332078' , 'Petrolina' , null, 'Rua Quarenta e Seis' , 22.30 , 'Joaquim', 'Luiz' , 'Campos' , '287101988' , '88uh' , true , '2016-04-04' , 'uizjoaquim@hotmail.com' , '1990-04-30'),
- ('79317880797' , '0001' , '23416393000114', '82600130' , 'Curitiba' , null , 'Rua Bernardo Rosenmann' , 0, 'Alana' , 'Rodrigues', 'Mello', '2368088' , '34f4' , true , '2016-09-11' , 'alana_rodriques@gmail.com' , '1993-06-06'),
- ('52125191105' , '0002' , '23416393000114', '77820026' , 'Araguaina' , null, 'Rua 16' , 0, 'Luana', 'Barbosa' , 'Pinto' , '1994566' , '9jf4' , true , '2016-09-11' , 'luaninha_babrbosa@gmail.com' , '1996-06-06'),
- ('50130428361' , '0001' , '23416393000114', '77016638' , 'Palmas' , null , 'Quadra 509 Sul Alameda 7' , 0, 'Agatha', 'Vasconcelos' , 'Belarmino' , '4526174' , 'f56g' , true , '2016-03-04', 'agatinha_bb@gmail.com' , '1999-09-09'),
- ('96468793068' , '0001' , '23416393000114', '49069186' , 'Aracaju', null, 'Rua do Sol' , 0 , 'Camila' , 'Castro' , 'Raimundo' , '3199788' , 'kj004' , true , '2016-09-18', 'camila_racastro@gmail.com' , '1992-02-20'),
- ('16512268903' , '0002', '23416393000114', '72876134' , 'Valparaíso de Goiás' , null, 'Quadra 37' , 23.33, 'Valkiria' , 'Queiroz' , 'Calado' , '4241822' , 'kd3io4' , true , '2016-02-12' , 'valqueiros@outlook.com' , '1960-03-07'),
- ('07617589689' , '0002' , '23416393000114', '89280577' , 'São Bento do Sul' , null, 'Rua Zanzibar' , 0, 'Angelica' , 'Meneses' , 'da Silva' , '4764955' , 'i4hfi4h' , false , '2017-02-05' , 'angelica_mene@outlook.com' , '1992-12-11');
- -- TABELA DE TELEFONE DE CLIENTE createdyes 13
- # ----------------------ALTERANDO VALORES ---------------------
- CREATE TABLE telefone_cliente (
- CPF char(11) not null,
- telefone char(10),
- CONSTRAINT telefone_cliente_pk primary key (CPF, telefone),
- CONSTRAINT fk_telefonecliente foreign key (CPF) references cliente (CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela telefone_cliente
- INSERT INTO telefone_cliente ( CPF, telefone) VALUES
- ('54501233290' , '8134564432'),
- ('25251145314' , '8199890765'),
- ('77658476358' , '8599690359'),
- ('07617589689' , '4899097820'),
- ('07617589689' , '8191913012'),
- ('96468793068' , '7934876650'),
- ('96468793068' , '7988786534'),
- ('50519774647' , '8133234567');
- -- TABELA DE SUGESTAO createdyes 13
- CREATE TABLE sugestao (
- CPF_cliente char(11) not null,
- id char(4),
- dia date,
- descricao varchar(30) not null,
- primary key (id),
- CONSTRAINT fk_sugestao foreign key (CPF_cliente) references cliente (CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela sugestao
- INSERT INTO sugestao (CPF_cliente, id, dia , descricao) VALUES
- ('54501233290' , '0001' , '2016-02-12' , 'mais entregadores'),
- ('54501233290' , '0002' , '2016-03-09' , 'mais entregadores'),
- ('54501233290' , '0003' , '2016-03-09' , 'mais entregadores'),
- ('54501233290' , '0004' , '2016-03-09' , 'mais entregadores'),
- ('54501233290' , '0005' , '2016-03-09' , 'mais entregadores'),
- ('54501233290' , '0006' , '2016-03-09' , 'mais entregadores'),
- ('54501233290' , '0007' , '2016-03-09' , 'mais entregadores'),
- ('54501233290' , '0008' , '2016-03-09' , 'mais entregadores'),
- ('54501233290' , '0009' , '2016-03-09' , 'mais entregadores');
- -- TABELA DE RECLAMACAO createdyes 13
- CREATE TABLE reclamacao (
- CPF_cliente char(11) not null,
- id char(4),
- descricao varchar(30) not null,
- motivo varchar(20),
- data_ocorrido date not null,
- data_reclamacao date,
- primary key (id),
- CONSTRAINT fk_reclamacao foreign key (CPF_cliente) references cliente (CPF) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- inserindo valores na tabela reclamacao
- INSERT INTO reclamacao ( CPF_cliente , id , motivo, data_ocorrido, data_reclamacao) VALUES
- ('54501233290' , '0001' , 'atendimento muito demorado', '2016-03-09' , '2016-03-13'),
- ('54501233290' , '0002' , 'produto estava perto de vencer', '2016-03-09' , '2016-03-13'),
- ('54501233290' , '0003' , 'o entregador nao chegou', '2016-03-01' , '2016-03-20'),
- ('54501233290' , '0004' , 'erraram o endereco de entrega', '2016-03-09' , '2016-03-13'),
- ('54501233290' , '0005' , 'atendimento muito demorado', '2016-03-09' , '2016-03-10'),
- ('54501233290' , '0006' , 'site fora do ar', '2016-04-01' , '2016-04-01'),
- ('54501233290' , '0007' , 'atendimento muito demorado', '2016-03-09' , '2016-03-13');
- -- TABELA DE PROMOCAO createdyes 13
- CREATE TABLE promocao (
- cod char(4),
- seq_filial char(4) not null,
- cnpj_matriz char(14) not null,
- nome varchar(30),
- data_inicio date not null,
- percentual_reducao float not null CHECK ( percentual_reducao > 0 ),
- data_fim date,
- obs varchar(30),
- descricao varchar(50),
- primary key (cod),
- foreign key (seq_filial ) references filial (seq),
- foreign key (cnpj_matriz) references filial(CNPJ_Matriz)
- );
- -- inserindo valores na tabela promocao OK
- INSERT INTO promocao (cod, seq_filial , cnpj_matriz , nome , data_inicio, percentual_reducao , data_fim, obs, descricao) VALUES
- ('0001' , '0001 ', '23416393000114', 'Um barato no pedaco' , '2017-02-05', 0.13 , '2017-03-05' , 'n inclui importados' , 'promocao para laticinios'),
- ('0002' , '0001' , '23416393000114', 'Queima de estoque' , '2016-12-22' , 0.33 , '2016-12-31' , NULL , NULL),
- ('0003' , '0002', '23416393000114','Mes da verdura' , '2017-08-12' , 0.26 , '2017-10-12' , 'n inclui conservas' , 'promocao para hortifruti' ),
- ('0004' , '0002' , '23416393000114', 'Mes da conserva' , '2017-11-20' , 0.21 , '2017-12-20', NULL , 'apenas conservas' ),
- ('0005 ', '0001' , '23416393000114', 'Desinfetantes em queima' , '2018-01-02' , 0.24 , '2018-02-02' , NULL , 'apenas desinfetantes'),
- ('0006' , '0002' , '23416393000114', 'Promocao de amaciante' , '2017-09-15' , 0.12, '2017-11-15' , NULL , 'amaciantes nacionais'),
- ('0007' , '0001' , '23416393000114', 'Laticinios vao a loucura' , '2018-01-02', 0.29, '2018-03-02' , NULL , 'reducao de preco laticinios'),
- ('0008' , '0002' , '23416393000114','Promocao de Sabao em po' , '2017-06-15' , 0.19 , '2017-07-15' , NULL , 'promocao sabao em po');
- -- TABELA DE ITEM PEDIDO createdyes 13
- CREATE TABLE item_pedido (
- seq char(4),
- cod_produto_ref char(4) not null,
- cod_pedido_fornecedor char(4) not null,
- quantidade int not null CHECK (quantidade > 0) ,
- preco_unitario float not null CHECK (preco_unitario > 0),
- primary key (seq),
- foreign key (cod_produto_ref) references produto_ref (cod),
- foreign key (cod_pedido_fornecedor) references pedido_fornecedor(cod)
- );
- -- INSERT INTO item_pedido (seq , cod_produto_ref , cod_pedido_fornecedor, quantidade , preco_unitario) VALUES
- -- TABELA DE LOTE createdyes 13
- CREATE TABLE lote (
- cod char(4),
- cod_pedido_fornecedor char(4) not null,
- descricao varchar(30),
- data_chegada date not null,
- primary key( cod) ,
- foreign key (cod_pedido_fornecedor) references pedido_fornecedor (cod)
- );
- -- INSERT INTO lote ( cod, cod_pedido_fornecedor, descricao , data_chegada)
- -- TABELA DE ITEM DE ESTOQUE createdyes 13
- CREATE TABLE item_estoque (
- seq char(4),
- cod_lote char(4),
- id_estoque char(4),
- cod_produto char(4),
- id_avaria char(4) not null,
- id_prateleira char(4) not null,
- data_validade date not null,
- data_fabricacao date not null,
- data_entrada date not null,
- valor_compra float CHECK (valor_compra > 0),
- quantidade int CHECK (quantidade > 0),
- primary key (seq),
- foreign key (cod_lote) references lote (cod),
- foreign key (id_estoque) references estoque (id),
- CONSTRAINT fk_produtoestoque foreign key ( cod_produto ) references produto_ref( cod) ON DELETE CASCADE ON UPDATE CASCADE,
- foreign key (id_avaria ) references avaria ( id),
- foreign key (id_prateleira ) references prateleira ( codigo)
- );
- -- INSERT INTO item_estoque (cod_lote, id_estoque , cod_produto , id_avaria , id_prateleira , data_validade ,
- /* data_fabricacao , data_entrada , valor_compra, quantidade)
- */
- -- TABELA DE PERDA DE PRODUTO createdyes 13
- CREATE TABLE perda (
- seq char(4),
- cod_lote char(4),
- cod_produto char(4),
- id_estoque char(4),
- cpf_gerente char(11) not null,
- dia date not null ,
- quantidade_perdida int CHECK (quantidade_perdida > 0) ,
- motivo varchar(80),
- primary key (seq),
- key(cod_lote , cod_produto , id_estoque),
- foreign key (cpf_gerente) references gerente (cpf),
- CONSTRAINT fk_perdaitestoq foreign key ( id_estoque ) references item_estoque(id_estoque ) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT fk_perdalote foreign key (cod_lote) references item_estoque (cod_lote) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT fk_perdaprod foreign key (cod_produto) references item_estoque (cod_produto) ON DELETE CASCADE ON UPDATE CASCADE
- );
- -- INSERT INTO perda ( seq , cod_lote, cod_produto, id_estoque, cpf_gerente , dia , quantidade_perdida , motivo)
- -- TABELA DE RELACIONAMENTO TEM DE FUNCIONARIO createdyes 13
- CREATE TABLE tem (
- id_jornada char(4),
- id_turno char(4),
- id_dia char(4),
- CONSTRAINT tem_pk primary key (id_jornada , id_turno , id_dia ),
- CONSTRAINT tem_id_jornada foreign key (id_jornada) references jornadatrabalho(id),
- CONSTRAINT tem_id_turno foreign key (id_turno) references turno(cod),
- CONSTRAINT tem_id_dia foreign key (id_dia) references dia (sequencial)
- );
- -- inserindo valores na tabela tem
- INSERT INTO tem (id_jornada , id_turno, id_dia ) VALUES
- ('0001' , '0001' , '0001' ),
- ('0001' , '0002' , '0002' ),
- ('0001' , '0003' , '0003' ),
- ('0001' , '0002' , '0004' ),
- ('0001' , '0002' , '0005' ),
- ('0001' , '0002' , '0006' ),
- ('0001' , '0001' , '0007' ),
- ('0002' , '0010' , '0001' ),
- ('0002' , '0006' , '0005' ),
- ('0003' , '0009' , '0006' ),
- ('0004' , '0001' , '0001' );
- -- TABELA RELACIONAMENTO REALIZA CURSO createdyes 13
- CREATE TABLE realizacurso (
- seq char(4),
- cpf_fun char(11),
- id_curso char(4),
- dt_inicio date,
- dt_fim date,
- primary key (seq),
- foreign key (cpf_fun) references funcionario(CPF),
- foreign key (id_curso) references curso (id)
- );
- -- inserindo valores na tabela realiza_curso
- INSERT INTO realizacurso ( seq , cpf_fun , id_curso , dt_inicio , dt_fim) VALUES
- ('0001','77491222226', '2101' , '2016-02-13' , '2016-03-15' ),
- ('0002', '77491222226' , '8012' , '2016-04-09' , '2016-06-09' ),
- ('0003', '32568071001' , '2101' ,'2016-02-13' , '2016-03-15' ),
- ('0004', '45321186898' , '8012' , '2016-04-09' , '2016-06-09' ),
- ('0005', '77491222226' , '8012' , '2016-04-09' , '2016-06-09' ),
- ('0006' ,'14073416260' , '8012' , '2016-04-09' , '2016-06-09' ),
- ('0007', '88356795591' , '8012' , '2016-04-09' , '2016-06-09' );
- -- TABELA DE GERENCIA DE ESTOQUE/* createdyes 13
- CREATE TABLE gerencia_estoque (
- seq char(4),
- cpf_super_estoque char(11),
- id_estoque char(4),
- dt_fim date,
- dt_inicio date,
- primary key (seq),
- foreign key (cpf_super_estoque) references SupervisorEstoque (CPF),
- foreign key (id_estoque) references estoque(id)
- );
- -- inserindo valores na tabela gerencia_estoque
- INSERT INTO gerencia_estoque (seq, cpf_super_estoque, id_estoque , dt_fim, dt_inicio) VALUES
- ('0001' ,'14073416260' , '0000001' ,'2017-03-02' ,'2016-03-02'),
- ('0002', '85902755239' , '0000002' , '2017-04-15' , '2016-02-15'),
- ('0003', '88356795591' , '0000003' , '2016-01-01' , '2014-02-13'),
- ('0004', '14073416260' , '0000002 ' , '2013-06-22' , '2012-06-10'),
- ('0005', '85902755239' , '0000003' ,'2017-09-02', '2016-01-02' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement