Escolar Documentos
Profissional Documentos
Cultura Documentos
OPERADORES LOGICOS:
= IGUAL A:
-------------------------------------------------------------------------------------------------In (....):
Select * from cliente where cli_codigo in(2,4,6);
E A MESMA COISA QUE:
Select * from cliente where cli_codigo = 2 or
cli_codigo = 5 or cli_codigo =6;
NAS DUAS LINHAS ACIMA, IR LISTAR TODAS AS TUPLAS EM
QUE O CODIGO SEJA 2 OU 4 OU 6;
--------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------DISTINCT:
// N0
//
);
-------------------------------------------------------------------------------------------------DROP:
DESCRIBE CLIENTE;
--------------------------------------------------------------------------------------------------
DISTINCT:
// DELETA TODOS
--------------------------------------------------------------------------------------------------
TRUNCATE:
// ELIMINA TODS OS
FUNES DE AGREGAO:
AVG:
-------------------------------------------------------------------------------------------------SUM:
MIN:
NO MYSQL = AUTO_INCREMENT
AGRUPA DADOS:
RETORNA QUANTOS CLIENTES SO DO SEXO MASCULINO E
QUANTOS DO SEXO FEMININO.
--------------------------------------------------------------------------------------------------
TABELA CIDADE
// CRIA TABELA
(
CID_CODIGO INTEGER NOT NULL
AUTO_INCREMENT,
CID_NOME VARCHAR (30),
PRIMARY KEY (CID_CODIGO)
);
// INSERIR DADOS NA TABELA;
INSERT INTO CIDADES (CID_NOME) VALUES
(CARAZINHO);
CHAVE ESTRANGEIRA
FOREIGN KEY:
EFETUA LIGAES (RELAIONAMENTO) ENTRE AS TABELAS;
IMPLEMENTA INTEGRIDADE DOS DADOS.
--------------------------------------------------------------------------------------------------
//
CONNECT C: \ BANCO.FDB;
--------------------------------------------------------------------------------------------------
IBOCONSOLE - FIREBIRD
COMMIT:
-------------------------------------------------------------------------------------------------ROLLBACK:
ROLLBACK;
--------------------------------------------------------------------------------------------------
NDICES
NDICE USADO PARA AGILIZAR PESQUISAS DE SELEO DE DADOS
NAS TABELAS. O KEY SINONIMO DE INDICE.
// MOSTRA OS
// DELETAR
-------------------------------------------------------------------------------------------------FOREIGN:
GENERATOR:
TRIGGER:
USER SECURITY:
--------------------------------------------------------------------------------------------------
CREATEBD LOCADORA
PASSWORD:
ESPECIFICAR A SENHA:
DROPBD LOCADORA;
SELECT CURRENT_DATE;
AUTO_INCREMENTO: SERIAL
CONSTRAINT CHAVE_PRIMARY_FUNCIONARIO
PRIMARY KEY (FUN_CODIGO);
CONSTRAINT CHAVE_ESTRANGEIRA_CODBAIRRO
FOREIGN KEY (FUN_CODBAIRRO) REFERENCES BAIRRO
(BAI_CODIGO);
);
-------------------------------------------------------------------------------------------------ALTER:
// ATRIBUTO
-------------------------------------------------------------------------------------------------Concat:
SEQUENCE:
IMPORTANTE:
INTEIRO
TEXTO (40)
(ENDEREO)
TEXTO (10)
TEXTO (10)
(BAIRRO)
(CIDADE)
TEXTO (10)
TEXTO (14)
TEXTO (18)
TEXTO (20)
TEXTO (20)
TEXTO (20)
DATA
PES_DATANASC
PES_EMAIL
PES_SEXO
PES_ESTADOCIVIL
PES_FOTO
PES_OBSERVACAO
INTEIRO
TEXTO (30)
TEXTO (2)
INTEIRO
TEXTO (20)
DATA
TEXTO (50)
TEXTO (1 (M,F))
TEXTO (1 (C,V,S,D))
TEXTO (50)
TEXTO (80)
INTEIRO
TEXTO (20)
--------------------------------------------------------------------------------------------------
drop table
CURSOS_DO_PACOTE;
drop table
FUNCIONARIO;
CAR_CODIGO
INTEGER
not null,
CAR_NOME
VARCHAR(15)
not null,
constraint PK_CARGO
primary key
(CAR_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: CIDADE
*/
/
*===================
====================
====================
===*/
create table CIDADE (
CID_CODIGO
INTEGER
not null,
CID_NOME
VARCHAR(20)
not null,
CID_UF
VARCHAR(2),
constraint PK_CIDADE
primary key
(CID_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: CURSOS
*/
/
*===================
====================
====================
===*/
create table CURSOS (
CUR_CODIGO
INTEGER
not null,
CUR_NOME
VARCHAR(20)
not null,
CUR_ATIVO
CHAR(1)
not null,
constraint PK_CURSOS
primary key
(CUR_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table:
CURSOS_DO_PACOTE
*/
/
*===================
====================
====================
===*/
create table
CURSOS_DO_PACOTE (
PAC_CODIGO
INTEGER
not null,
CUR_CODIGO
INTEGER
not null,
constraint
PK_CURSOS_DO_PACO
TE primary key
(PAC_CODIGO,
CUR_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: DIA
*/
/
*===================
====================
====================
===*/
create table DIA (
DIA_CODIGO
INTEGER
not null,
DIA_NOME
VARCHAR(20),
constraint PK_DIA primary
key (DIA_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: ENDERECO
*/
/
*===================
====================
====================
===*/
create table ENDERECO (
END_CODIGO
INTEGER
not null,
END_NOME
VARCHAR(20)
not null,
constraint
PK_ENDERECO primary
key (END_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: FUNCIONARIO
*/
/
*===================
====================
====================
===*/
create table
FUNCIONARIO (
FUN_CODIGO
INTEGER
not null,
CAR_CODIGO
INTEGER
not null,
BAI_CODIGO
INTEGER
not null,
CID_CODIGO
INTEGER
not null,
END_CODIGO
INTEGER
not null,
FUN_NOME
VARCHAR(40)
not null,
FUN_NUMERO
VARCHAR(10),
FUN_COMPLEMENTO
VARCHAR(10),
FUN_CEP
CHAR(9),
FUN_CPF
CHAR(11),
FUN_RG
VARCHAR(18),
FUN_EMAIL
VARCHAR(50),
FUN_FONECOM
CHAR(16),
FUN_FONERES
CHAR(16),
FUN_FONECEL
CHAR(16),
FUN_FOTO
VARCHAR(50),
FUN_OBS
VARCHAR(50),
FUN_DATANASC
DATE,
FUN_DATADAEMISSAO
DATE,
FUN_SEXO
CHAR(1),
FUN_ESTADOCIVIL
CHAR(1),
FUN_APELIDO
VARCHAR(10),
constraint
PK_FUNCIONARIO
primary key
(FUN_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: HORARIO
*/
/
*===================
====================
====================
===*/
create table HORARIO (
HOR_CODIGO
INTEGER
not null,
HOR_NOME
VARCHAR(20),
constraint PK_HORARIO
primary key
(HOR_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: LOGIN
*/
/
*===================
====================
====================
===*/
create table LOGIN (
LOG_CODIGO
INTEGER
not null,
LOG_NOME
VARCHAR(20)
not null,
LOG_LOGIN
VARCHAR(20),
LOG_SENHA
VARCHAR(20),
LOG_NIVEL
CHAR(4)
not null,
constraint PK_LOGIN
primary key
(LOG_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: MATRICULA
*/
/
*===================
====================
====================
===*/
create table MATRICULA (
MAT_CODIGO
INTEGER
not null,
PES_CODIGO
INTEGER
not null,
PAC_CODIGO
INTEGER
not null,
MAT_DATACAD
DATE,
MAT_NUMPARCELA
INTEGER,
MAT_VALORPARCELA
NUMERIC(10,2),
MAT_VALORTOTAL
NUMERIC(10,2),
MAT_SALDO
NUMERIC(10,2),
MAT_NOTAALUNO
NUMERIC(4,2),
MAT_FREQUENCIA
NUMERIC(2),
MAT_OBSERVACAO
VARCHAR(60),
MAT_EMISSAOCERTIFIC
ADO CHAR(1),
constraint
PK_MATRICULA primary
key (MAT_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: MIDIA
*/
/
*===================
====================
====================
===*/
create table MIDIA (
MID_CODIGO
INTEGER
not null,
MID_NOME
VARCHAR(20)
not null,
constraint PK_MIDIA
primary key
(MID_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: PACOTE
*/
/
*===================
====================
====================
===*/
create table PACOTE (
PAC_CODIGO
INTEGER
not null,
PAC_NOME
VARCHAR(30),
PAC_VALOR
NUMERIC(10),
PAC_DURACAO
INTEGER,
PAC_ATIVO
CHAR(1),
PAC_QUANTHORAS
INTEGER,
PAC_NUMPARC
INTEGER,
PAC_CERTLINHA1
VARCHAR(60),
PAC_CERTLINHA2
VARCHAR(60),
constraint PK_PACOTE
primary key
(PAC_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: PARCELAS
*/
/
*===================
====================
====================
===*/
create table PARCELAS (
PARC_PARCCOD
INTEGER
not null,
MAT_CODIGO
INTEGER
not null,
PARC_VALORPARC
NUMERIC(10,2),
PARC_DATAVENC
DATE,
PARC_DATAPAGTO
DATE,
PARC_JUROS
NUMERIC(10,2),
PARC_DESCONTO
NUMERIC(10,2),
PARC_VALORPAGO
NUMERIC(10,2),
PARC_SALDO
NUMERIC(10,2),
PARC_NUMBANCARIO
CHAR(11),
constraint PK_PARCELAS
primary key
(PARC_PARCCOD)
);
/
*===================
====================
====================
===*/
/* Table: PESSOA
*/
/
*===================
====================
====================
===*/
create table PESSOA (
PES_CODIGO
INTEGER
not null,
END_CODIGO
INTEGER
not null,
BAI_CODIGO
INTEGER
not null,
CID_CODIGO
INTEGER
not null,
MID_CODIGO
INTEGER
not null,
PES_NOME
VARCHAR(40)
not null,
PES_NUMERO
VARCHAR(10),
PES_COMPLEMENTO
VARCHAR(10),
PES_CEP
VARCHAR(10),
PES_CPF
VARCHAR(14)
not null,
PES_RG
VARCHAR(18)
not null,
PES_FONERES
VARCHAR(20),
PES_FONECOM
VARCHAR(20),
PES_FONECEL
VARCHAR(20)
not null,
PES_DATACAD
DATE,
PES_DATANASC
DATE,
PES_EMAIL
VARCHAR(50),
PES_SEXO
CHAR(1),
PES_ESTADOCIVIL
CHAR(1),
PES_FOTO
VARCHAR(50),
PES_OBSERVACAO
VARCHAR(80),
constraint PK_PESSOA
primary key
(PES_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table:
RESPONSAVEL_PELO_
ALUNO
*/
/
*===================
====================
====================
===*/
create table
RESPONSAVEL_PELO_
ALUNO (
PES_CODIGO
INTEGER
not null,
PES_PES_CODIGO
INTEGER
not null,
constraint
PK_RESPONSAVEL_PEL
O_ALUNO primary key
(PES_CODIGO,
PES_PES_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: SALA
*/
/
*===================
====================
====================
===*/
create table SALA (
SAL_CODIGO
INTEGER
not null,
SAL_NOME
VARCHAR(20)
not null,
constraint PK_SALA
primary key
(SAL_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table: TURMAS
*/
/
*===================
====================
====================
===*/
create table TURMAS (
TUR_CODIGO
INTEGER
not null,
PAC_CODIGO
INTEGER
not null,
SAL_CODIGO
INTEGER
not null,
DIA_CODIGO
INTEGER
not null,
HOR_CODIGO
INTEGER
not null,
FUN_CODIGO
INTEGER
not null,
TUR_DATAINICIO
DATE,
TUR_PREVISAOFIM
DATE,
TUR_DATAFIM
DATE,
TUR_CAPACIDADE
INTEGER,
TUR_INSCRITOS
INTEGER,
TUR_VAGASREST
INTEGER,
TUR_STATUS
CHAR(1),
TUR_DIA
CHAR(10),
TUR_HORARIO
CHAR(10),
constraint PK_TURMAS
primary key
(TUR_CODIGO)
);
/
*===================
====================
====================
===*/
/* Table:
TURMA_MATRICULA
*/
/
*===================
====================
====================
===*/
create table
TURMA_MATRICULA (
TUR_CODIGO
INTEGER
not null,
MAT_CODIGO
INTEGER
not null,
constraint
PK_TURMA_MATRICULA
primary key
(TUR_CODIGO,
MAT_CODIGO)
);
alter table
CURSOS_DO_PACOTE
add constraint
FK_CURSOS_D_CURSO
S_DO_PACOTE foreign
key (PAC_CODIGO)
references PACOTE
(PAC_CODIGO);
alter table
CURSOS_DO_PACOTE
add constraint
FK_CURSOS_D_CURSO
S_DO_CURSOS foreign
key (CUR_CODIGO)
references CURSOS
(CUR_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_BAIRRO
_DO_BAIRRO foreign key
(BAI_CODIGO)
references BAIRRO
(BAI_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_CARGO
_DO__CARGO foreign
key (CAR_CODIGO)
references CARGO
(CAR_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_CIDADE
_DO_CIDADE foreign key
(CID_CODIGO)
references CIDADE
(CID_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_ENDERE
CO__ENDERECO foreign
key (END_CODIGO)
references
ENDERECO
(END_CODIGO);
alter table MATRICULA
add constraint
FK_MATRICUL_ALUNO_
DA__PESSOA foreign key
(PES_CODIGO)
references PESSOA
(PES_CODIGO);
alter table MATRICULA
add constraint
FK_MATRICUL_PACOTE
_DA_PACOTE foreign key
(PAC_CODIGO)
references PACOTE
(PAC_CODIGO);
alter table PARCELAS
add constraint
FK_PARCELAS_PARCEL
AS__MATRICUL foreign
key (MAT_CODIGO)
references
MATRICULA
(MAT_CODIGO);
alter table PESSOA
add constraint
FK_PESSOA_BAIRRO_D
A_BAIRRO foreign key
(BAI_CODIGO)
references BAIRRO
(BAI_CODIGO);
alter table PESSOA
add constraint
FK_PESSOA_CIDADE_D
A_CIDADE foreign key
(CID_CODIGO)
references CIDADE
(CID_CODIGO);
--------------------------------------------------------------------------------------------------
alter table
RESPONSAVEL_PELO_ALUNO
drop constraint
FK_RESPONSA_RESPONSAV_P
ESSOA_1;
alter table
RESPONSAVEL_PELO_ALUNO
drop constraint
FK_RESPONSA_RESPONSAV_P
ESSOA;
alter table TURMAS
drop constraint
FK_TURMAS_DIA_DA_TU_DIA;
alter table TURMAS
drop constraint
FK_TURMAS_HORARIO_D_HOR
ARIO;
alter table TURMAS
drop constraint
FK_TURMAS_PACOTE_DA_PAC
OTE;
alter table TURMAS
drop constraint
FK_TURMAS_PROFESSOR_FUN
CIONA;
alter table TURMAS
drop constraint
FK_TURMAS_SALA_DA_T_SALA;
alter table TURMA_MATRICULA
drop constraint
FK_TURMA_MA_TURMA_MAT_T
URMAS;
alter table TURMA_MATRICULA
drop constraint
FK_TURMA_MA_TURMA_MAT_M
ATRICUL;
drop table BAIRRO cascade
constraints;
drop table CARGO cascade
constraints;
drop table CIDADE cascade
constraints;
drop table CURSOS cascade
constraints;
drop index
CURSOS_DO_PACOTE2_FK;
drop index
CURSOS_DO_PACOTE_FK;
drop table CURSOS_DO_PACOTE
cascade constraints;
drop table DIA cascade constraints;
drop table ENDERECO cascade
constraints;
drop index
CIDADE_DOS_FUNCIONARIOS_F
K;
drop index
BAIRRO_DO_FUNCIONARIO_FK;
drop index
ENDERECO_DO_FUNCIONARIO_
FK;
drop index
PACOTE_DA_MATRICULA_FK;
drop index
ALUNO_DA_MATRICULA_FK;
drop table MATRICULA cascade
constraints;
drop table MIDIA cascade
constraints;
drop table PACOTE cascade
constraints;
drop index
PARCELAS_DA_MATRICULA_FK;
drop table PARCELAS cascade
constraints;
drop index
CIDADE_DAS_PESSOAS_FK;
drop index
BAIRRO_DA_PESSOA_FK;
drop index
ENDERECO_DA_PESSOA_FK;
drop index
MIDIA_DA_PESSOA_FK;
drop table PESSOA cascade
constraints;
drop index
RESPONSAVEL_PELO_ALUNO2_
FK;
drop index
RESPONSAVEL_PELO_ALUNO_F
K;
drop index
CARGO_DO_FUNCIONARIO_FK;
drop table
RESPONSAVEL_PELO_ALUNO
cascade constraints;
drop index
PROFESSOR_DA_TURMA_FK;
drop index
HORARIO_DA_TURMA_FK;
drop index DIA_DA_TURMA_FK;
drop index
PACOTE_DA_TURMA_FK;
drop table TURMAS cascade
constraints;
drop index
TURMA_MATRICULA2_FK;
drop index
TURMA_MATRICULA_FK;
drop table TURMA_MATRICULA
cascade constraints;
create table BAIRRO (
BAI_CODIGO
INTEGER
not null,
BAI_NOME
VARCHAR2(20)
not
null,
constraint PK_BAIRRO primary
key (BAI_CODIGO)
);
create table CARGO (
CAR_CODIGO
INTEGER
not null,
CAR_NOME
VARCHAR2(15)
not
null,
constraint PK_CARGO primary
key (CAR_CODIGO)
);
create table CIDADE (
CID_CODIGO
INTEGER
not null,
CID_NOME
VARCHAR2(20)
not
null,
CID_UF
VARCHAR2(2),
constraint PK_CIDADE primary
key (CID_CODIGO)
);
create table CURSOS (
CUR_CODIGO
INTEGER
not null,
CUR_NOME
VARCHAR2(20)
not
null,
CUR_ATIVO
CHAR(1)
not null,
constraint PK_CURSOS primary
key (CUR_CODIGO)
);
create table
CURSOS_DO_PACOTE (
PAC_CODIGO
INTEGER
not null,
CUR_CODIGO
INTEGER
not null,
constraint
PK_CURSOS_DO_PACOTE
primary key (PAC_CODIGO,
CUR_CODIGO)
);
create index
CURSOS_DO_PACOTE_FK on
CURSOS_DO_PACOTE (
PAC_CODIGO ASC
);
create index
CURSOS_DO_PACOTE2_FK on
CURSOS_DO_PACOTE (
CUR_CODIGO ASC
);
create table DIA (
DIA_CODIGO
INTEGER
not null,
DIA_NOME
VARCHAR2(20),
constraint PK_DIA primary key
(DIA_CODIGO)
);
create table ENDERECO (
END_CODIGO
INTEGER
not null,
END_NOME
VARCHAR2(20)
not
null,
constraint PK_ENDERECO
primary key (END_CODIGO)
);
create table FUNCIONARIO (
FUN_CODIGO
INTEGER
not null,
CAR_CODIGO
INTEGER
not null,
BAI_CODIGO
INTEGER
not null,
CID_CODIGO
INTEGER
not null,
END_CODIGO
INTEGER
not null,
FUN_NOME
VARCHAR2(40)
not
null,
FUN_NUMERO
VARCHAR2(10),
FUN_COMPLEMENTO
VARCHAR2(10),
FUN_CEP
CHAR(9),
FUN_CPF
CHAR(11),
FUN_RG
VARCHAR2(18),
FUN_EMAIL
VARCHAR2(50),
FUN_FONECOM
CHAR(16),
FUN_FONERES
CHAR(16),
FUN_FONECEL
CHAR(16),
FUN_FOTO
VARCHAR2(50),
FUN_OBS
VARCHAR2(50),
FUN_DATANASC
DATE,
FUN_DATADAEMISSAO DATE,
FUN_SEXO
CHAR(1),
FUN_ESTADOCIVIL
CHAR(1),
FUN_APELIDO
VARCHAR2(10),
constraint PK_FUNCIONARIO
primary key (FUN_CODIGO)
);
create index
CARGO_DO_FUNCIONARIO_FK
on FUNCIONARIO (
CAR_CODIGO ASC
);
create index
ENDERECO_DO_FUNCIONARIO_
FK on FUNCIONARIO (
END_CODIGO ASC
);
create index
BAIRRO_DO_FUNCIONARIO_FK
on FUNCIONARIO (
BAI_CODIGO ASC
);
create index
CIDADE_DOS_FUNCIONARIOS_F
K on FUNCIONARIO (
CID_CODIGO ASC
);
create table HORARIO (
HOR_CODIGO
INTEGER
not null,
HOR_NOME
VARCHAR2(20),
constraint PK_HORARIO primary
key (HOR_CODIGO)
);
create table LOGIN (
LOG_CODIGO
INTEGER
not null,
LOG_NOME
VARCHAR2(20)
not
null,
LOG_LOGIN
VARCHAR2(20),
LOG_SENHA
VARCHAR2(20),
LOG_NIVEL
CHAR(4)
not null,
constraint PK_LOGIN primary key
(LOG_CODIGO)
);
create table MATRICULA (
MAT_CODIGO
INTEGER
not null,
PES_CODIGO
INTEGER
not null,
PAC_CODIGO
INTEGER
not null,
MAT_DATACAD
DATE,
MAT_NUMPARCELA
INTEGER,
MAT_VALORPARCELA
NUMBER(10,2),
MAT_VALORTOTAL
NUMBER(10,2),
MAT_SALDO
NUMBER(10,2),
MAT_NOTAALUNO
NUMBER(4,2),
MAT_FREQUENCIA
NUMBER(2),
MAT_OBSERVACAO
VARCHAR2(60),
MAT_EMISSAOCERTIFICADO
CHAR(1),
constraint PK_MATRICULA
primary key (MAT_CODIGO)
);
create index
ALUNO_DA_MATRICULA_FK on
MATRICULA (
PES_CODIGO ASC
);
create index
PACOTE_DA_MATRICULA_FK on
MATRICULA (
PAC_CODIGO ASC
);
create table MIDIA (
MID_CODIGO
INTEGER
not null,
MID_NOME
VARCHAR2(20)
not
null,
constraint PK_MIDIA primary key
(MID_CODIGO)
);
create table PACOTE (
PAC_CODIGO
INTEGER
not null,
PAC_NOME
VARCHAR2(30),
PAC_VALOR
NUMBER(10),
PAC_DURACAO
INTEGER,
PAC_ATIVO
CHAR(1),
PAC_QUANTHORAS
INTEGER,
PAC_NUMPARC
INTEGER,
PAC_CERTLINHA1
VARCHAR2(60),
PAC_CERTLINHA2
VARCHAR2(60),
constraint PK_PACOTE primary
key (PAC_CODIGO)
);
create table PARCELAS (
PARC_PARCCOD
INTEGER
not null,
MAT_CODIGO
INTEGER
not null,
PARC_VALORPARC
NUMBER(10,2),
PARC_DATAVENC
DATE,
PARC_DATAPAGTO
DATE,
PARC_JUROS
NUMBER(10,2),
PARC_DESCONTO
NUMBER(10,2),
PARC_VALORPAGO
NUMBER(10,2),
PARC_SALDO
NUMBER(10,2),
PARC_NUMBANCARIO
CHAR(11),
constraint PK_PARCELAS
primary key (PARC_PARCCOD)
);
create index
PARCELAS_DA_MATRICULA_FK
on PARCELAS (
MAT_CODIGO ASC
);
create table PESSOA (
PES_CODIGO
INTEGER
not null,
END_CODIGO
INTEGER
not null,
BAI_CODIGO
INTEGER
not null,
CID_CODIGO
INTEGER
not null,
MID_CODIGO
INTEGER
not null,
PES_NOME
VARCHAR2(40)
not
null,
PES_NUMERO
VARCHAR2(10),
PES_COMPLEMENTO
VARCHAR2(10),
PES_CEP
VARCHAR2(10),
PES_CPF
VARCHAR2(14)
not
null,
PES_RG
VARCHAR2(18)
not
null,
PES_FONERES
VARCHAR2(20),
PES_FONECOM
VARCHAR2(20),
PES_FONECEL
VARCHAR2(20)
not
null,
PES_DATACAD
DATE,
PES_DATANASC
DATE,
PES_EMAIL
VARCHAR2(50),
PES_SEXO
CHAR(1),
PES_ESTADOCIVIL
CHAR(1),
PES_FOTO
VARCHAR2(50),
PES_OBSERVACAO
VARCHAR2(80),
constraint PK_PESSOA primary
key (PES_CODIGO)
);
create index
MIDIA_DA_PESSOA_FK on
PESSOA (
MID_CODIGO ASC
);
create index
ENDERECO_DA_PESSOA_FK on
PESSOA (
END_CODIGO ASC
);
create index
BAIRRO_DA_PESSOA_FK on
PESSOA (
BAI_CODIGO ASC
);
create index
CIDADE_DAS_PESSOAS_FK on
PESSOA (
CID_CODIGO ASC
);
create table
RESPONSAVEL_PELO_ALUNO (
PES_CODIGO
INTEGER
not null,
PES_PES_CODIGO
INTEGER
not null,
constraint
PK_RESPONSAVEL_PELO_ALUN
O primary key (PES_CODIGO,
PES_PES_CODIGO)
);
create index
RESPONSAVEL_PELO_ALUNO_F
K on
RESPONSAVEL_PELO_ALUNO (
PES_CODIGO ASC
);
create index
RESPONSAVEL_PELO_ALUNO2_
FK on
RESPONSAVEL_PELO_ALUNO (
PES_PES_CODIGO ASC
);
create table SALA (
SAL_CODIGO
INTEGER
not null,
SAL_NOME
VARCHAR2(20)
not
null,
constraint PK_SALA primary key
(SAL_CODIGO)
);
create table TURMAS (
TUR_CODIGO
INTEGER
not null,
PAC_CODIGO
INTEGER
not null,
SAL_CODIGO
INTEGER
not null,
DIA_CODIGO
INTEGER
not null,
HOR_CODIGO
INTEGER
not null,
FUN_CODIGO
INTEGER
not null,
TUR_DATAINICIO
DATE,
TUR_PREVISAOFIM
DATE,
TUR_DATAFIM
DATE,
TUR_CAPACIDADE
INTEGER,
TUR_INSCRITOS
INTEGER,
TUR_VAGASREST
INTEGER,
TUR_STATUS
CHAR(1),
TUR_DIA
CHAR(10),
TUR_HORARIO
CHAR(10),
constraint PK_TURMAS primary
key (TUR_CODIGO)
);
create index
PACOTE_DA_TURMA_FK on
TURMAS (
PAC_CODIGO ASC
);
create index DIA_DA_TURMA_FK
on TURMAS (
DIA_CODIGO ASC
);
create index
HORARIO_DA_TURMA_FK on
TURMAS (
HOR_CODIGO ASC
);
create index
PROFESSOR_DA_TURMA_FK on
TURMAS (
FUN_CODIGO ASC
);
create index
SALA_DA_TURMA_FK on
TURMAS (
SAL_CODIGO ASC
);
create table TURMA_MATRICULA
(
TUR_CODIGO
INTEGER
not null,
MAT_CODIGO
INTEGER
not null,
constraint
PK_TURMA_MATRICULA primary
key (TUR_CODIGO,
MAT_CODIGO)
);
create index
TURMA_MATRICULA_FK on
TURMA_MATRICULA (
TUR_CODIGO ASC
);
create index
TURMA_MATRICULA2_FK on
TURMA_MATRICULA (
MAT_CODIGO ASC
);
alter table CURSOS_DO_PACOTE
add constraint
FK_CURSOS_D_CURSOS_DO_P
ACOTE foreign key
(PAC_CODIGO)
references PACOTE
(PAC_CODIGO);
alter table CURSOS_DO_PACOTE
add constraint
FK_CURSOS_D_CURSOS_DO_C
URSOS foreign key
(CUR_CODIGO)
references CURSOS
(CUR_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_BAIRRO_DO_BAI
RRO foreign key (BAI_CODIGO)
references BAIRRO
(BAI_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_CARGO_DO__CA
RGO foreign key (CAR_CODIGO)
references CARGO
(CAR_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_CIDADE_DO_CID
ADE foreign key (CID_CODIGO)
references CIDADE
(CID_CODIGO);
alter table FUNCIONARIO
add constraint
FK_FUNCIONA_ENDERECO__EN
DERECO foreign key
(END_CODIGO)
references ENDERECO
(END_CODIGO);
alter table MATRICULA
add constraint
FK_MATRICUL_ALUNO_DA__PE
SSOA foreign key (PES_CODIGO)
references PESSOA
(PES_CODIGO);
alter table MATRICULA
add constraint
FK_MATRICUL_PACOTE_DA_PA
COTE foreign key (PAC_CODIGO)
references PACOTE
(PAC_CODIGO);
alter table PARCELAS
add constraint
FK_PARCELAS_PARCELAS__MA
TRICUL foreign key
(MAT_CODIGO)
references MATRICULA
(MAT_CODIGO);
alter table PESSOA
add constraint
FK_PESSOA_BAIRRO_DA_BAIRR
O foreign key (BAI_CODIGO)
references BAIRRO
(BAI_CODIGO);
alter table PESSOA
add constraint
FK_PESSOA_CIDADE_DA_CIDA
DE foreign key (CID_CODIGO)
references CIDADE
(CID_CODIGO);
add constraint
FK_TURMAS_HORARIO_D_HOR
ARIO foreign key (HOR_CODIGO)
references HORARIO
(HOR_CODIGO);
alter table TURMAS
add constraint
FK_TURMAS_PACOTE_DA_PAC
OTE foreign key (PAC_CODIGO)
references PACOTE
(PAC_CODIGO);
alter table TURMAS
add constraint
FK_TURMAS_PROFESSOR_FUN
CIONA foreign key (FUN_CODIGO)
references FUNCIONARIO
(FUN_CODIGO);
alter table TURMAS
add constraint
FK_TURMAS_SALA_DA_T_SALA
foreign key (SAL_CODIGO)
references SALA
(SAL_CODIGO);
alter table TURMA_MATRICULA
add constraint
FK_TURMA_MA_TURMA_MAT_T
URMAS foreign key
(TUR_CODIGO)
references TURMAS
(TUR_CODIGO);
alter table TURMA_MATRICULA
add constraint
FK_TURMA_MA_TURMA_MAT_M
ATRICUL foreign key
(MAT_CODIGO)
references MATRICULA
(MAT_CODIGO);
--------------------------------------------------------------------------------------------------
/
*==============
===============
===============
===============
===*/
/* DBMS name:
Microsoft SQL
Server 2008
*/
/* Created on:
17/01/2015
16:18:50
*/
/
*==============
===============
===============
===============
===*/
if exists (select 1
from
sysobjects
where id =
object_id('BAIRRO')
and type =
'U')
drop table
BAIRRO
go
if exists (select 1
from
sysobjects
where id =
object_id('CARGO')
and type =
'U')
drop table
CARGO
go
if exists (select 1
from
sysobjects
where id =
object_id('CIDADE')
and type =
'U')
drop table
CIDADE
go
if exists (select 1
from
sysobjects
where id =
object_id('CURSOS'
)
and type =
'U')
drop table
CURSOS
go
if exists (select 1
from
sysindexes
where id =
object_id('CURSOS
_DO_PACOTE')
and name
=
'CURSOS_DO_PAC
OTE2_FK'
and indid >
0
and indid <
255)
drop index
CURSOS_DO_PAC
OTE.CURSOS_DO
_PACOTE2_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('CURSOS
_DO_PACOTE')
and name
=
'CURSOS_DO_PAC
OTE_FK'
and indid >
0
and indid <
255)
drop index
CURSOS_DO_PAC
OTE.CURSOS_DO
_PACOTE_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('CURSOS
_DO_PACOTE')
and type =
'U')
drop table
CURSOS_DO_PAC
OTE
go
if exists (select 1
from
sysobjects
where id =
object_id('DIA')
and type =
'U')
drop table DIA
go
if exists (select 1
from
sysobjects
where id =
object_id('ENDERE
CO')
and type =
'U')
drop table
ENDERECO
go
if exists (select 1
from
sysindexes
where id =
object_id('FUNCION
ARIO')
and name
=
'CIDADE_DOS_FU
NCIONARIOS_FK'
and indid >
0
and indid <
255)
drop index
FUNCIONARIO.CID
ADE_DOS_FUNCI
ONARIOS_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('FUNCION
ARIO')
and name
=
'BAIRRO_DO_FUN
CIONARIO_FK'
and indid >
0
and indid <
255)
drop index
FUNCIONARIO.BAI
RRO_DO_FUNCIO
NARIO_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('FUNCION
ARIO')
and name
=
'ENDERECO_DO_F
UNCIONARIO_FK'
and indid >
0
and indid <
255)
drop index
FUNCIONARIO.EN
DERECO_DO_FUN
CIONARIO_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('FUNCION
ARIO')
and name
=
'CARGO_DO_FUN
CIONARIO_FK'
and indid >
0
and indid <
255)
drop index
FUNCIONARIO.CA
RGO_DO_FUNCIO
NARIO_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('FUNCION
ARIO')
and type =
'U')
drop table
FUNCIONARIO
go
'ALUNO_DA_MATR
ICULA_FK'
and indid >
0
and indid <
255)
drop index
MATRICULA.ALUN
O_DA_MATRICULA
_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('HORARI
O')
and type =
'U')
drop table
HORARIO
go
if exists (select 1
from
sysobjects
where id =
object_id('MATRICU
LA')
and type =
'U')
drop table
MATRICULA
go
if exists (select 1
from
sysobjects
where id =
object_id('LOGIN')
and type =
'U')
drop table LOGIN
go
if exists (select 1
from
sysobjects
where id =
object_id('MIDIA')
and type =
'U')
drop table MIDIA
go
if exists (select 1
from
sysindexes
where id =
object_id('MATRICU
LA')
and name
=
'PACOTE_DA_MAT
RICULA_FK'
and indid >
0
and indid <
255)
drop index
MATRICULA.PACO
TE_DA_MATRICUL
A_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('PACOTE')
and type =
'U')
drop table
PACOTE
go
if exists (select 1
from
sysindexes
where id =
object_id('MATRICU
LA')
and name
=
if exists (select 1
from
sysindexes
where id =
object_id('PARCELA
S')
and name
=
'PARCELAS_DA_M
ATRICULA_FK'
and indid >
0
and indid <
255)
drop index
PARCELAS.PARCE
LAS_DA_MATRICU
LA_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('PARCELA
S')
and type =
'U')
drop table
PARCELAS
go
if exists (select 1
from
sysindexes
where id =
object_id('PESSOA'
)
and name
=
'CIDADE_DAS_PE
SSOAS_FK'
and indid >
0
and indid <
255)
drop index
PESSOA.CIDADE_
DAS_PESSOAS_F
K
go
if exists (select 1
from
sysindexes
where id =
object_id('PESSOA'
)
and name
=
'BAIRRO_DA_PES
SOA_FK'
and indid >
0
and indid <
255)
drop index
PESSOA.BAIRRO_
DA_PESSOA_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('PESSOA'
)
and name
=
'ENDERECO_DA_P
ESSOA_FK'
and indid >
0
and indid <
255)
drop index
PESSOA.ENDERE
CO_DA_PESSOA_
FK
go
if exists (select 1
from
sysindexes
where id =
object_id('PESSOA'
)
and name
=
'MIDIA_DA_PESSO
A_FK'
and indid >
0
and indid <
255)
drop index
PESSOA.MIDIA_DA
_PESSOA_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('PESSOA'
)
and type =
'U')
drop table
PESSOA
go
if exists (select 1
from
sysindexes
where id =
object_id('RESPON
SAVEL_PELO_ALU
NO')
and name
=
'RESPONSAVEL_P
ELO_ALUNO2_FK'
and indid >
0
and indid <
255)
drop index
RESPONSAVEL_P
ELO_ALUNO.RESP
ONSAVEL_PELO_A
LUNO2_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('RESPON
SAVEL_PELO_ALU
NO')
and name
=
'RESPONSAVEL_P
ELO_ALUNO_FK'
and indid >
0
and indid <
255)
drop index
RESPONSAVEL_P
ELO_ALUNO.RESP
ONSAVEL_PELO_A
LUNO_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('RESPON
SAVEL_PELO_ALU
NO')
and type =
'U')
drop table
RESPONSAVEL_P
ELO_ALUNO
go
if exists (select 1
from
sysobjects
where id =
object_id('SALA')
and type =
'U')
drop table SALA
go
if exists (select 1
from
sysindexes
where id =
object_id('TURMAS'
)
and name
=
'SALA_DA_TURMA
_FK'
and indid >
0
drop index
TURMAS.DIA_DA_
TURMA_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('TURMAS'
)
and name
=
'PACOTE_DA_TUR
MA_FK'
and indid >
0
and indid <
255)
drop index
TURMAS.PACOTE_
DA_TURMA_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('TURMAS'
)
and type =
'U')
drop table
TURMAS
go
if exists (select 1
from
sysindexes
where id =
object_id('TURMA_
MATRICULA')
and name
=
'TURMA_MATRICU
LA2_FK'
and indid >
0
and indid <
255)
drop index
TURMA_MATRICU
LA.TURMA_MATRI
CULA2_FK
go
if exists (select 1
from
sysindexes
where id =
object_id('TURMA_
MATRICULA')
and name
=
'TURMA_MATRICU
LA_FK'
and indid >
0
and indid <
255)
drop index
TURMA_MATRICU
LA.TURMA_MATRI
CULA_FK
go
if exists (select 1
from
sysobjects
where id =
object_id('TURMA_
MATRICULA')
and type =
'U')
drop table
TURMA_MATRICU
LA
go
/
*==============
===============
===============
===============
===*/
/* Table: BAIRRO
*/
/
*==============
===============
===============
===============
===*/
create table
BAIRRO (
BAI_CODIGO
int
not
null,
BAI_NOME
varchar(20)
not null,
constraint
PK_BAIRRO
primary key
nonclustered
(BAI_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table: CARGO
*/
/
*==============
===============
===============
===============
===*/
create table
CARGO (
CAR_CODIGO
int
not
null,
CAR_NOME
varchar(15)
not null,
constraint
PK_CARGO
primary key
nonclustered
(CAR_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table: CIDADE
*/
/
*==============
===============
===============
===============
===*/
create table
CIDADE (
CID_CODIGO
int
not
null,
CID_NOME
varchar(20)
not null,
CID_UF
varchar(2)
null,
constraint
PK_CIDADE
primary key
nonclustered
(CID_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table: CURSOS
*/
/
*==============
===============
===============
===============
===*/
create table
CURSOS (
CUR_CODIGO
int
not
null,
CUR_NOME
varchar(20)
not null,
CUR_ATIVO
char(1)
not
null,
constraint
PK_CURSOS
primary key
nonclustered
(CUR_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table:
CURSOS_DO_PAC
OTE
*/
/
*==============
===============
===============
===============
===*/
create table
CURSOS_DO_PAC
OTE (
PAC_CODIGO
int
not
null,
CUR_CODIGO
int
not
null,
constraint
PK_CURSOS_DO_
PACOTE primary
key (PAC_CODIGO,
CUR_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
CURSOS_DO_PAC
OTE_FK
*/
/
*==============
===============
===============
===============
===*/
create index
CURSOS_DO_PAC
OTE_FK on
CURSOS_DO_PAC
OTE (
PAC_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
CURSOS_DO_PAC
OTE2_FK
*/
/
*==============
===============
===============
===============
===*/
create index
CURSOS_DO_PAC
OTE2_FK on
CURSOS_DO_PAC
OTE (
CUR_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Table: DIA
*/
/
*==============
===============
===============
===============
===*/
create table DIA (
DIA_CODIGO
int
not
null,
DIA_NOME
varchar(20)
null,
constraint PK_DIA
primary key
nonclustered
(DIA_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table:
ENDERECO
*/
/
*==============
===============
===============
===============
===*/
create table
ENDERECO (
END_CODIGO
int
not
null,
END_NOME
varchar(20)
not null,
constraint
PK_ENDERECO
primary key
nonclustered
(END_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table:
FUNCIONARIO
*/
/
*==============
===============
===============
===============
===*/
create table
FUNCIONARIO (
FUN_CODIGO
int
not
null,
CAR_CODIGO
int
not
null,
BAI_CODIGO
int
not
null,
CID_CODIGO
int
not
null,
END_CODIGO
int
not
null,
FUN_NOME
varchar(40)
not null,
FUN_NUMERO
varchar(10)
null,
FUN_COMPLEMEN
TO
varchar(10)
null,
FUN_CEP
char(9)
null,
FUN_CPF
char(11)
null,
FUN_RG
varchar(18)
null,
FUN_EMAIL
varchar(50)
null,
FUN_FONECOM
char(16)
null,
FUN_FONERES
char(16)
null,
FUN_FONECEL
char(16)
null,
FUN_FOTO
varchar(50)
null,
FUN_OBS
varchar(50)
null,
FUN_DATANASC
datetime
null,
FUN_DATADAEMIS
SAO datetime
null,
FUN_SEXO
char(1)
null,
FUN_ESTADOCIVIL
char(1)
null,
FUN_APELIDO
varchar(10)
null,
constraint
PK_FUNCIONARIO
primary key
nonclustered
(FUN_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
CARGO_DO_FUNC
IONARIO_FK
*/
/
*==============
===============
===============
===============
===*/
create index
CARGO_DO_FUNC
IONARIO_FK on
FUNCIONARIO (
CAR_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
ENDERECO_DO_F
UNCIONARIO_FK
*/
/
*==============
===============
===============
===============
===*/
create index
ENDERECO_DO_F
UNCIONARIO_FK
on FUNCIONARIO (
END_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
BAIRRO_DO_FUN
CIONARIO_FK
*/
/
*==============
===============
===============
===============
===*/
create index
BAIRRO_DO_FUN
CIONARIO_FK on
FUNCIONARIO (
BAI_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
CIDADE_DOS_FUN
CIONARIOS_FK
*/
/
*==============
===============
===============
===============
===*/
create index
CIDADE_DOS_FUN
CIONARIOS_FK on
FUNCIONARIO (
CID_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Table: HORARIO
*/
/
*==============
===============
===============
===============
===*/
create table
HORARIO (
HOR_CODIGO
int
not
null,
HOR_NOME
varchar(20)
null,
constraint
PK_HORARIO
primary key
nonclustered
(HOR_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table: LOGIN
*/
/
*==============
===============
===============
===============
===*/
create table LOGIN
(
LOG_CODIGO
int
not
null,
LOG_NOME
varchar(20)
not null,
LOG_LOGIN
varchar(20)
null,
LOG_SENHA
varchar(20)
null,
LOG_NIVEL
char(4)
not
null,
constraint
PK_LOGIN primary
key nonclustered
(LOG_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table:
MATRICULA
*/
/
*==============
===============
===============
===============
===*/
create table
MATRICULA (
MAT_CODIGO
int
not
null,
PES_CODIGO
int
not
null,
PAC_CODIGO
int
not
null,
MAT_DATACAD
datetime
null,
MAT_NUMPARCEL
A
int
null,
MAT_VALORPARC
ELA
numeric(10,2)
null,
MAT_VALORTOTAL
numeric(10,2)
null,
MAT_SALDO
numeric(10,2)
null,
MAT_NOTAALUNO
numeric(4,2)
null,
MAT_FREQUENCIA
numeric(2)
null,
MAT_OBSERVACA
O
varchar(60)
null,
MAT_EMISSAOCE
RTIFICADO char(1)
null,
constraint
PK_MATRICULA
primary key
nonclustered
(MAT_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
ALUNO_DA_MATRI
CULA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
ALUNO_DA_MATRI
CULA_FK on
MATRICULA (
PES_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
PACOTE_DA_MAT
RICULA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
PACOTE_DA_MAT
RICULA_FK on
MATRICULA (
PAC_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Table: MIDIA
*/
/
*==============
===============
===============
===============
===*/
create table MIDIA (
MID_CODIGO
int
not
null,
MID_NOME
varchar(20)
not null,
constraint
PK_MIDIA primary
key nonclustered
(MID_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table: PACOTE
*/
/
*==============
===============
===============
===============
===*/
create table
PACOTE (
PAC_CODIGO
int
not
null,
PAC_NOME
varchar(30)
null,
PAC_VALOR
numeric(10)
null,
PAC_DURACAO
int
null,
PAC_ATIVO
char(1)
null,
PAC_QUANTHORA
S
int
null,
PAC_NUMPARC
int
null,
PAC_CERTLINHA1
varchar(60)
null,
PAC_CERTLINHA2
varchar(60)
null,
constraint
PK_PACOTE
primary key
nonclustered
(PAC_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table: PARCELAS
*/
/
*==============
===============
===============
===============
===*/
create table
PARCELAS (
PARC_PARCCOD
int
not
null,
MAT_CODIGO
int
not
null,
PARC_VALORPAR
C
numeric(10,2)
null,
PARC_DATAVENC
datetime
null,
PARC_DATAPAGT
O
datetime
null,
PARC_JUROS
numeric(10,2)
null,
PARC_DESCONTO
numeric(10,2)
null,
PARC_VALORPAG
O
numeric(10,2)
null,
PARC_SALDO
numeric(10,2)
null,
PARC_NUMBANCA
RIO char(11)
null,
constraint
PK_PARCELAS
primary key
nonclustered
(PARC_PARCCOD)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
PARCELAS_DA_M
ATRICULA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
PARCELAS_DA_M
ATRICULA_FK on
PARCELAS (
MAT_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Table: PESSOA
*/
/
*==============
===============
===============
===============
===*/
create table
PESSOA (
PES_CODIGO
int
not
null,
END_CODIGO
int
not
null,
BAI_CODIGO
int
not
null,
CID_CODIGO
int
not
null,
MID_CODIGO
int
not
null,
PES_NOME
varchar(40)
not null,
PES_NUMERO
varchar(10)
null,
PES_COMPLEMEN
TO
varchar(10)
null,
PES_CEP
varchar(10)
null,
PES_CPF
varchar(14)
not null,
PES_RG
varchar(18)
not null,
PES_FONERES
varchar(20)
null,
PES_FONECOM
varchar(20)
null,
PES_FONECEL
varchar(20)
not null,
PES_DATACAD
datetime
null,
PES_DATANASC
datetime
null,
PES_EMAIL
varchar(50)
null,
PES_SEXO
char(1)
null,
PES_ESTADOCIVIL
char(1)
null,
PES_FOTO
varchar(50)
null,
PES_OBSERVACA
O
varchar(80)
null,
constraint
PK_PESSOA
primary key
nonclustered
(PES_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
MIDIA_DA_PESSO
A_FK
*/
/
*==============
===============
===============
===============
===*/
create index
MIDIA_DA_PESSO
A_FK on PESSOA (
MID_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
ENDERECO_DA_P
ESSOA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
ENDERECO_DA_P
ESSOA_FK on
PESSOA (
END_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
BAIRRO_DA_PESS
OA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
BAIRRO_DA_PESS
OA_FK on PESSOA
(
BAI_CODIGO ASC
)
go
===============
===*/
create table
RESPONSAVEL_P
ELO_ALUNO (
PES_CODIGO
int
not
null,
/
*==============
===============
===============
===============
===*/
/* Index:
CIDADE_DAS_PES
SOAS_FK
*/
/
*==============
===============
===============
===============
===*/
create index
CIDADE_DAS_PES
SOAS_FK on
PESSOA (
CID_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
RESPONSAVEL_P
ELO_ALUNO_FK
*/
/
*==============
===============
===============
===============
===*/
create index
RESPONSAVEL_P
ELO_ALUNO_FK
on
RESPONSAVEL_P
ELO_ALUNO (
PES_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Table:
RESPONSAVEL_P
ELO_ALUNO
*/
/
*==============
===============
===============
PES_PES_CODIG
O
int
not null,
constraint
PK_RESPONSAVE
L_PELO_ALUNO
primary key
(PES_CODIGO,
PES_PES_CODIG
O)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
RESPONSAVEL_P
ELO_ALUNO2_FK
*/
/
*==============
===============
===============
===============
===*/
create index
RESPONSAVEL_P
ELO_ALUNO2_FK
on
RESPONSAVEL_P
ELO_ALUNO (
PES_PES_CODIG
O ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Table: SALA
*/
/
*==============
===============
===============
===============
===*/
create table SALA (
SAL_CODIGO
int
not
null,
SAL_NOME
varchar(20)
not null,
constraint
PK_SALA primary
key nonclustered
(SAL_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Table: TURMAS
*/
/
*==============
===============
===============
===============
===*/
create table
TURMAS (
TUR_CODIGO
int
not
null,
PAC_CODIGO
int
not
null,
SAL_CODIGO
int
not
null,
DIA_CODIGO
int
not
null,
HOR_CODIGO
int
not
null,
FUN_CODIGO
int
not
null,
TUR_DATAINICIO
datetime
null,
TUR_PREVISAOFI
M
datetime
null,
TUR_DATAFIM
datetime
null,
TUR_CAPACIDADE
int
null,
TUR_INSCRITOS
int
null,
TUR_VAGASREST
int
null,
TUR_STATUS
char(1)
null,
TUR_DIA
char(10)
null,
TUR_HORARIO
char(10)
null,
constraint
PK_TURMAS
primary key
nonclustered
(TUR_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
PACOTE_DA_TUR
MA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
PACOTE_DA_TUR
MA_FK on
TURMAS (
PAC_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
DIA_DA_TURMA_F
K
*/
/
*==============
===============
===============
===============
===*/
create index
DIA_DA_TURMA_F
K on TURMAS (
DIA_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
HORARIO_DA_TU
RMA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
HORARIO_DA_TU
RMA_FK on
TURMAS (
HOR_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
PROFESSOR_DA_
TURMA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
PROFESSOR_DA_
TURMA_FK on
TURMAS (
FUN_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
SALA_DA_TURMA
_FK
*/
/
*==============
===============
===============
===============
===*/
create index
SALA_DA_TURMA
_FK on TURMAS (
SAL_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Table:
TURMA_MATRICU
LA
*/
/
*==============
===============
===============
===============
===*/
create table
TURMA_MATRICU
LA (
TUR_CODIGO
int
not
null,
MAT_CODIGO
int
not
null,
constraint
PK_TURMA_MATRI
CULA primary key
(TUR_CODIGO,
MAT_CODIGO)
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
TURMA_MATRICU
LA_FK
*/
/
*==============
===============
===============
===============
===*/
create index
TURMA_MATRICU
LA_FK on
TURMA_MATRICU
LA (
TUR_CODIGO ASC
)
go
/
*==============
===============
===============
===============
===*/
/* Index:
TURMA_MATRICU
LA2_FK
*/
/
*==============
===============
===============
===============
===*/
create index
TURMA_MATRICU
LA2_FK on
TURMA_MATRICU
LA (
MAT_CODIGO ASC
)
go
--------------------------------------------------------------------------------------------------