Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DROP DATABASE IF EXISTS teste;
- CREATE DATABASE teste;
- USE teste;
- DROP TABLE IF EXISTS musico;
- CREATE TABLE musico (
- CPF int NOT NULL,
- Nome char NOT NULL,
- Endereco char NOT NULL,
- Telefone char NOT NULL,
- Salario float NOT NULL,
- PRIMARY KEY (CPF)
- );
- DROP TABLE IF EXISTS produtor;
- CREATE TABLE produtor (
- CPF_Produtor int NOT NULL,
- QTD_ALB int NOT NULL,
- PRIMARY KEY (CPF_Produtor),
- FOREIGN KEY (CPF_Produtor) references musico (CPF)
- );
- DROP TABLE IF EXISTS album;
- CREATE TABLE album (
- ID_Album int not null,
- CPF_Produtor int not null,
- Formato char not null,
- DATA_DIR_AUT date not null,
- Titulo char not null,
- PRIMARY KEY (ID_Album),
- FOREIGN KEY (CPF_Produtor) references produtor (CPF_Produtor)
- );
- DROP TABLE IF EXISTS instrumento;
- CREATE TABLE instrumento (
- Nome_Ins char NOT NULL,
- Tom char NOT NULL,
- ID_Instr int NOT NULL,
- PRIMARY KEY (ID_Instr)
- );
- DROP TABLE IF EXISTS musica;
- CREATE TABLE musica (
- ID_Musica int NOT NULL,
- CPF_Autor int NOT NULL,
- CPF_Produtor int NOT NULL,
- ID_Album int NOT NULL,
- Titulo char not null,
- PRIMARY KEY (ID_Musica),
- FOREIGN KEY (CPF_Autor) references musico(CPF),
- FOREIGN KEY (CPF_Produtor) references produtor(CPF_Produtor),
- FOREIGN KEY (ID_Album) references album(ID_Album)
- );
- DROP TABLE IF EXISTS orienta;
- CREATE TABLE orienta (
- CPF_Musico int not null,
- ID_Instrumento int not null,
- PRIMARY KEY (CPF_Musico),
- FOREIGN KEY(CPF_Musico) references musico(CPF),
- FOREIGN KEY(ID_Instrumento) references instrumento(ID_Instr)
- );
- DROP TABLE IF EXISTS usado_em;
- CREATE TABLE usado_em (
- ID_Instrumento int not null,
- ID_Musica int not null,
- Data_Uso date not null,
- PRIMARY KEY (ID_Instrumento, ID_Musica),
- FOREIGN KEY (ID_Instrumento) references instrumento (ID_Instr),
- FOREIGN KEY(ID_Musica) references musica (ID_Musica)
- );
- DROP TABLE IF EXISTS produz;
- CREATE TABLE produz (
- ID_Musica int not null,
- CPF_Produto int not null,
- PRIMARY KEY (ID_Musica),
- FOREIGN KEY (ID_Musica) references musica(ID_Musica),
- FOREIGN KEY(CPF_Produtor) references produtor(CPF_Produtor)
- );
- DROP TABLE IF EXISTS publica;
- CREATE TABLE publica (
- CPF_Produtor int not null,
- ID_album int not null,
- PRIMARY KEY (CPF_Produtor),
- FOREIGN KEY (CPF_Produtor) references produtor(CPF_Produtor),
- FOREIGN KEY (ID_Album) references album(ID_Album)
- );
- DROP TABLE IF EXISTS contida_em;
- CREATE TABLE contida_em (
- ID_Musica int not null,
- ID_Album int not null,
- PRIMARY KEY (ID_Musica, ID_Album),
- FOREIGN KEY(ID_Musica) references musica(ID_Musica),
- FOREIGN KEY(ID_Album) references album(ID_Album)
- );
- DROP TABLE IF EXISTS interpreta;
- CREATE TABLE interpreta (
- CPF_Musico int not null,
- ID_Musica int not null,
- PRIMARY KEY (CPF_Musico, ID_Musica),
- FOREIGN KEY (CPF_Musico) references musico(CPF),
- FOREIGN KEY (ID_Musica) references musica(ID_Musica)
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement