TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Vau vaujhuahuva

Por:   •  5/5/2015  •  Artigo  •  352 Palavras (2 Páginas)  •  287 Visualizações

Página 1 de 2

create table Estado(

SgEstado char(2),

NmEstado varchar(20),

primary key (SgEstado)

);

create table Cidade(

CdCidade integer,

SgEstado char(2),

NmCidade varchar(20),

primary key (CdCidade,SgEstado),

foreign key (SgEstado) references Estado (SgEstado)

);

create table Bairro(

CdBairro integer,

CdCidade integer,

SgEstado char(2),

NmBairro varchar(50),

primary key (CdBairro,CdCidade,SgEstado),

foreign key (CdCidade,SgEstado) references Cidade (CdCidade,SgEstado)

);

create table Vendedor(

CdVendedor integer,

NmVendedor varchar(40),

NmEndereco varchar(40),

CPF char(11),

Cidade varchar(20),

Bairro varchar(20),

Estado char(2),

Telefone varchar(20),

email varchar(80),

primary key (CdVendedor)

);

create table Imovel(

CdImovel integer,

CdVendedor integer,

CdBairro integer,

CdCidade integer,

SgEstado char(2),

NmEndereco varchar(40),

NmAreaUtil decimal(10,2),

NrAreaTotal decimal(10,2),

DsImovel varchar(300),

VlPreco decimal(16,2),

NrOferta integer,

StVendido char(1),

DtLanc date,

Imovel_Indicado integer,

primary key (CdImovel),

foreign key (Imovel_Indicado) references Imovel (CdImovel),

foreign key(CdBairro,CdCidade,SgEstado) references Bairro (CdBairro,CdCidade,SgEstado)

);

create table Comprador(

CdComprador integer,

Nmvendedor varchar(40),

NmEndereco varchar(40),

NrCpf char(11),

NmCidade varchar(20),

NmBairro varchar(20),

SgEstado char(2),

telefone varchar(20),

email varchar(50),

primary key(CdComprador)

);

create table Oferta(

CdImovel integer,

CdComprador integer,

VlOferta decimal(16,2),

DtOferta date,

primary key(CdImovel,CdComprador),

Foreign Key(CdImovel) references Imovel(CdImovel),

Foreign Key(CdComprador) references Comprador(CdComprador)

);

create table Faixa_Imovel(

CdFaixa integer,

NmFaixa varchar(30),

VlMinimo decimal(14,2),

Vlmaximo decimal(14,2),

primary key (CdFaixa)

);

alter table Comprador

add NmComprador varchar(50);

drop table Vendedor,Comprador,Imovel,Oferta,Estado,Cidade,Bairro, faixa_imovel cascade;

drop table Imovel,Oferta cascade;

insert into Estado values ('SP','Sao Paulo');

insert into Estado values ('Mg','Uberaba');

insert into Cidade values (1, 'SP','Sao Paulo');

insert into Cidade values (2, 'Mg','Ouro Branco');

insert into Cidade values (3, 'SP','Guarulhos');

insert into Bairro values (1, 1,'SP', 'Vila Carbone');

insert into Bairro values (2, 2,'Mg', 'Sao Cristovao');

insert into Vendedor values (1,'Douglas','Marcus Cherem','23091098869','Uberaba','Sao Cristovao','Mg','3333-3333','douglas@seila.com');

insert into Vendedor values (2,'sss','xxx','23091098869','Uberaba','wwww','Mg','1111-11111','xxxx');

insert into Imovel values (1,1,2,2,'Mg','Marcus Cherem',15,30,'ffff',350000,1,'s','25/01/2015',null);

insert into Imovel values (2,2,1,1,'SP','Urumila',70,140,'adsasd',10000000,4,'n','15/10/1995',1);

insert into Imovel values (4,2,2,2,'Mg','Urumila',70,140,'adsasd',500000,4,'n','15/10/1995',1);

insert into Imovel values (3,2,1,1,'SP','Urumila',70,140,'adsasd',10000000,4,'n','15/10/1995',1);

insert into Comprador values (1,'Douglas','Marcus Cherem','11111111111','Uberaba','Sao

...

Baixar como (para membros premium)  txt (5.1 Kb)   pdf (56 Kb)   docx (14.1 Kb)  
Continuar por mais 1 página »
Disponível apenas no TrabalhosGratuitos.com