create table banco( IDBC number(4), nome varchar2(30) NOT NULL, primary key(IDBC) ); create table leilao( num number(3), IDBC number(4), data date NOT NULL, local varchar2(20) NOT NULL, primary key (num,idbc), foreign key(IDBC) references banco ); create table bem( Id_bem number(4), Valor_min number(8,2) NOT NULL, primary key(Id_bem) ); create table endereco( CEP varchar2(8), bairro varchar2(15) NOT NULL, cidade varchar2(15) NOT NULL, estado varchar2(2) NOT NULL, primary key(CEP) ); create table imovel( escritura varchar2(4), Id_bem number(4) NOT NULL UNIQUE, CEP varchar2(8) NOT NULL, primary key(escritura), foreign key(CEP) references endereco, foreign key(Id_bem) references bem ); create table automovel( chassi varchar2(6), Id_bem number(4) NOT NULL UNIQUE, placa varchar2(7) UNIQUE, ano varchar2(4) NOT NULL, primary key(chassi), foreign key (Id_bem) references bem ); create table arrematante( CPF varchar2(11) primary key, nome varchar2(30) NOT NULL, CEP varchar2(8) NOT NULL, data_inscricao date NOT NULL, foreign key(CEP) references endereco ); create table telefone( CPF varchar2(11), DDD varchar2(3), numero varchar2(8) NOT NULL, foreign key(CPF) references arrematante, primary key(CPF) ); create table leiloeiro( cpf varchar2(11), nome varchar2(30) NOT NULL, cep varchar2(8) NOT NULL, numero_de_inscricao varchar2(4) NOT NULL, primary key(cpf), foreign key(CEP) references endereco ); create table oferta_rel( id_bem number(4), num number(3), idbc number(4), cpf_leiloeiro varchar2(11) NOT NULL, foreign key(id_bem) references bem, foreign key(cpf_leiloeiro) references leiloeiro, foreign key(num,idbc) references leilao, primary key(id_bem,num,idbc) ); create table oferta_ent( id_bem number(4), num number(3) NOT NULL, idbc number(4) NOT NULL, cpf_leiloeiro varchar2(11) NOT NULL, preco number(8,2) NOT NULL, qtd_lances number(4) NOT NULL, cpf_arrematante varchar2(11) NOT NULL, primary key(id_bem), foreign key(id_bem) references bem, foreign key(cpf_leiloeiro) references leiloeiro, foreign key(num,idbc) references leilao, foreign key(cpf_arrematante) references arrematante ); create table patrocina( data date, pessoa1 varchar2(11), pessoa2 varchar2(11), foreign key(pessoa1) references arrematante, foreign key(pessoa2) references arrematante, primary key(data,pessoa1,pessoa2) ); ;