Baixe o app para aproveitar ainda mais
Prévia do material em texto
--BANCO DE DADOS UTILIZADO: MICROSOFT SQL SERVER --CRIANDO O BANCO DE DADOS create database exercicio --TABELA SITUAÇÃO create table situacao ( id_situacao integer not null, situacao varchar(10) not null ) --ADICIONANDO A CHAVE PRIMARIA alter table situacao add constraint pk_situacao primary key (id_situacao) --TABELA SOCIO create table socio ( id_socio integer not null, nome varchar(256) not null, cpf varchar not null, email varchar(256), id_situacao integer not null ) --ADICIONANDO A CHAVE PRIMARIA alter table socio add constraint pk_socio primary key (id_socio) --ADICIONANDO A CHAVE ESTRANGEIRA alter table socio add constraint fk_socio_situacao foreign key (id_situacao) references situacao (id_situacao) --TABELA MARCA create table marca ( id_marca integer not null, marca varchar(128) not null ) --ADICIONANDO A CHAVE PRIMARIA alter table marca add constraint pk_marca primary key (id_marca) --TABELA CARRO create table carro ( id_carro integer not null, modelo varchar(128) not null, cor varchar(64) not null, placa varchar(10) not null, id_socio integer not null, id_marca integer not null ) --ADICIONANDO A CHAVE PRIMARIA alter table carro add constraint pk_carro primary key (id_carro) --ADICIONANDO A CHAVE ESTRANGEIRA alter table carro add constraint fk_carro_socio foreign key (id_socio) references socio (id_socio) --ADICIONANDO A CHAVE ESTRANGEIRA alter table carro add constraint fk_carro_marca foreign key (id_marca) references marca (id_marca)
Compartilhar