Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drop table Editora cascade constraint;
- drop sequence seq_editora;
- create sequence seq_editora
- start with 1
- increment by 1;
- create table Editora (
- cod_editora number not null,
- nomeEditora varchar(100) not null,
- primary key(cod_editora),
- unique (nomeEditora)
- );
- drop table Tags cascade constraint;
- drop sequence seq_tags;
- create sequence seq_tags
- start with 1
- increment by 1;
- create table Tags (
- cod_tag number not null,
- nomeTag varchar(100) not null,
- primary key(cod_tag),
- unique (nomeTag)
- );
- drop sequence seq_socios;
- create sequence seq_socios
- start with 1
- increment by 1;
- drop table Socios cascade constraint;
- create table Socios (
- cod_socio number not null,
- nomeSocio varchar(100) not null,
- data_insc date not null,
- morada varchar(100) not null,
- sexo char(1) not null CHECK (sexo IN ('F' , 'M')),
- primary key (cod_socio)
- );
- drop sequence seq_autores;
- create sequence seq_autores
- start with 1
- increment by 1;
- drop table Autores cascade constraint;
- create table Autores (
- cod_autor number not null,
- nomeAutor varchar(100) not null,
- primary key(cod_autor),
- unique (nomeAutor)
- );
- drop sequence seq_empregados;
- create sequence seq_empregados
- start with 1
- increment by 1;
- drop table Empregados cascade constraint;
- create table Empregados (
- cod_empregado number not null,
- nomeEmpregado varchar(100) not null,
- salario number not null,
- morada varchar(100) not null,
- sexo char(1) not null CHECK (sexo IN ('F' , 'M')),
- primary key(cod_empregado)
- );
- drop table Periodic_pub cascade constraint;
- create table Periodic_pub (
- ISSN number not null,
- nomePeriodic varchar(100) not null,
- volume number,
- edicao number not null,
- data_pub date not null,
- cod_editora number not null,
- primary key(ISSN),
- foreign key (cod_editora) references Editora
- );
- drop table Caracteriza_periodic cascade constraint;
- create table Caracteriza_periodic (
- cod_tag number not null,
- ISSN number not null,
- primary key(cod_tag, ISSN),
- foreign key (cod_tag) references Tags,
- foreign key (ISSN) references Periodic_Pub
- );
- drop table Localizacao_fisica cascade constraint;
- drop sequence seq_loc_fisica;
- create sequence seq_loc_fisica
- start with 1
- increment by 1;
- create table Localizacao_fisica (
- cod_loc number not null,
- corredor varchar(3) not null,
- primary key(cod_loc),
- unique (corredor)
- );
- drop table Livros cascade constraint;
- create table Livros (
- ISBN number not null,
- nomeLivro varchar(100) not null,
- edicao number not null,
- data_pub date not null,
- cod_editora number not null,
- primary key(ISBN),
- foreign key (cod_editora) references Editora
- );
- drop table Caracteriza_livro cascade constraint;
- create table Caracteriza_livro (
- cod_tag number not null,
- ISBN number not null,
- primary key(cod_tag, ISBN),
- foreign key (cod_tag) references Tags,
- foreign key (ISBN) references Livros
- );
- drop table Livros_fisicos cascade constraint;
- drop sequence seq_livros_fisicos;
- create sequence seq_livros_fisicos
- start with 1
- increment by 1;
- create table Livros_fisicos (
- cod_livro number not null,
- ISBN number not null,
- cod_loc number not null,
- primary key (cod_livro),
- foreign key (ISBN) references Livros,
- foreign key (cod_loc) references Localizacao_fisica
- );
- drop table Escrito_por cascade constraint;
- create table Escrito_por (
- cod_autor number not null,
- ISBN number not null,
- primary key(cod_autor, ISBN),
- foreign key (cod_autor) references Autores,
- foreign key (ISBN) references Livros
- );
- drop table Solicitacao cascade constraint;
- create table Solicitacao (
- data_req date not null,
- cod_livro number not null,
- cod_socio number not null,
- resp_req number not null,
- foreign key (cod_livro) references Livros_fisicos,
- foreign key (cod_socio) references Socios,
- foreign key (resp_req) references Empregados (cod_empregado),
- primary key (data_req, cod_livro, cod_socio)
- );
- drop table Devolucao cascade constraint;
- create table Devolucao (
- data_dev date not null,
- data_req date not null,
- cod_livro number not null,
- cod_socio number not null,
- resp_dev number not null,
- foreign key (data_req, cod_livro, cod_socio) references Solicitacao (data_req, cod_livro, cod_socio),
- primary key (data_dev, data_req, cod_livro, cod_socio)
- );
Add Comment
Please, Sign In to add comment