Lógica de programação
Por: BiahCalciolari89 • 29/10/2015 • Projeto de pesquisa • 424 Palavras (2 Páginas) • 251 Visualizações
create database GREEN_AND_WHITE
use GREEN_AND_WHITE
create table alunos
(
id_aluno int not null,
nome varchar(45),
rg varchar(15),
telefone varchar(20),
endereco varchar (45),
cidade varchar (20),
cep varchar (8),
uf char (2),
primary key (id_aluno),
)
create table professores
(
id_professor int not null,
nome varchar (45),
telefone varchar(20),
endereço varchar (45),
cidade varchar (20),
cep varchar (8),
uf char (2),
salario money,
primary key (id_professor)
)
create table Turmas_0
(
id_turma int,
id_aluno int,
id_professor int,
constraint PK_turmas_0 primary key (id_turma),
constraint FK_turmas_0_id_professor foreign key (id_professor) references professores (id_professor)
)
create table turma_01
(
id_professor int not null,
id_turma int not null,
id_aluno int not null,
constraint PK_turma_01 primary key (id_turma, id_professor, id_aluno),
constraint FK_turma_012 foreign key (id_professor) references professores (id_professor),
constraint FK_turma_013 foreign key (id_aluno) references alunos (id_aluno),
)
create table turma_02
(
id_professor int not null,
id_turma int not null,
id_aluno int not null,
constraint PK_turma_02 primary key (id_turma, id_professor, id_aluno),
constraint FK_turma_022 foreign key (id_professor) references professores (id_professor),
constraint FK_turma_023 foreign key (id_aluno) references alunos (id_aluno),
)
create table turma_03
(
id_professor int not null,
id_turma int not null,
id_aluno int not null,
constraint PK_turma_03 primary key (id_turma, id_professor, id_aluno),
constraint FK_turma_032 foreign key (id_professor) references professores (id_professor),
constraint FK_turma_033 foreign key (id_aluno) references alunos (id_aluno),
)
insert into turma_01 values (1,1,1)
insert into turma_01 values (1,1,2)
insert into turma_01 values (1,1,3)
insert into turma_01 values (1,1,4)
insert into turma_01 values (1,1,5)
insert into turma_02 values (2,2,1)
insert into turma_02 values (2,2,2)
insert into turma_02 values (2,2,3)
insert into turma_02 values (2,2,4)
insert into turma_02 values (2,2,5)
insert into turma_03 values (3,3,1)
insert into turma_03 values (3,3,2)
insert into turma_03 values (3,3,3)
insert into turma_03 values (3,3,4)
insert into turma_03 values (3,3,5)
insert into alunos values (1,'ANA MARIA TORRES','23.551.963-4','(11) 3264-0987','RUA CARLOS DRUMMOND N 14','SAO PAULO','01365511','SP')
insert
...