create table if not exists Projeto(
id_projeto Integer not null primary key auto_increment,
nome_projeto varchar(30)
);
create table if not exists Peça(
id_peça Integer not null primary key auto_increment,
nome_peça varchar(30),
id_projeto Integer not null, constraint foreign key(id_projeto) references Projeto(id_projeto)
);
create table if not exists Pessoa(
id_pessoa Integer not null primary key auto_increment,
nome_pessoa varchar(30),
id_projeto Integer not null, constraint foreign key(id_projeto) references Projeto(id_projeto)
);
insert into Projeto(nome_projeto) Values("A1");
insert into Projeto(nome_projeto) Values("A2");
insert into Projeto(nome_projeto) Values("A3");
insert into Projeto(nome_projeto) Values("A4");
insert into Peça(nome_peça,id_projeto) values("parafuso",1);
insert into Peça(nome_peça,id_projeto) values("prego",1);
insert into Peça(nome_peça,id_projeto) values("Joelho",2);
insert into Peça(nome_peça,id_projeto) values("tubo pvc",2);
insert into Peça(nome_peça,id_projeto) values("Dobradiça",3);
insert into Peça(nome_peça,id_projeto) values("Fechadura",3);
insert into Peça(nome_peça,id_projeto) values("Registro",4);
insert into Peça(nome_peça,id_projeto) values("Sifão",4);
insert into Pessoa(nome_pessoa,id_projeto) values("Davi",1);
insert into Pessoa(nome_pessoa,id_projeto) values("João",1);
insert into Pessoa(nome_pessoa,id_projeto) values("Pedro",1);
insert into Pessoa(nome_pessoa,id_projeto) values("Paulo",2);
insert into Pessoa(nome_pessoa,id_projeto) values("Marcos",2);
insert into Pessoa(nome_pessoa,id_projeto) values("Antônio",2);
insert into Pessoa(nome_pessoa,id_projeto) values("José",3);
insert into Pessoa(nome_pessoa,id_projeto) values("Jaime",3);
insert into Pessoa(nome_pessoa,id_projeto) values("Vitor",4);
insert into Pessoa(nome_pessoa,id_projeto) values("Joaquin",4);
select * from Pessoa where id_projeto = 1
select nome_projeto from Projeto where id_projeto = 1