


Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!



-- create CREATE TABLE artisti ( idArtista int NOT NULL, nome varchar (20), genere varchar (20), nazionalita varchar (20), note varchar (20), primary key (idArtista) ); CREATE TABLE registrazioni ( idRegistrazione int NOT NULL, titoloAlbum varchar (100), etichetta varchar (50), data date, nBrani int, durataTotale float, primary key (idRegistrazione) ); CREATE TABLE brani( idBrano int NOT NULL, titolo varchar (50), durata float, posizione int, idArtista int, idRegistrazione int, primary key (idBrano), foreign key (idArtista) REFERENCES artisti (idArtista), foreign key (idRegistrazione) REFERENCES registrazioni (idRegistrazione) ); -- insert INSERT INTO artisti VALUES (1, 'Mina', 'pop', 'Italiana', 'solo'), (2, 'Eminem', 'pop', 'Americano', 'solo'), (3, 'Pink Floyd', 'rock', 'Inglese', 'gruppo'), (4, 'Virgin', 'new wave', 'Irlandese', 'gruppo'), (5, 'David Bowie', 'pop', 'Inglese', 'solo'), (6, 'Beyonce', 'pop', 'Spagnolo', 'solo'); INSERT INTO registrazioni VALUES (1, 'The dark side of the moon', 'Harvest', '1973/03/01', 10, 43), (2, 'Animals', 'Harvest', '1977/01/21', 5, 41), (3, 'Aladdin Sane', 'rca', '1973/04/13', 10, 41), (4, 'Lemonade', 'parkwood', '2016/04/23', 12, 46),
(5, 'Infinite', 'web enternaiment', '1996/11/12', 3, 9), (6, 'Studio uno', 'rifi', '1965/03/13', 3, 30); INSERT INTO brani VALUES (1, 'Speak to me', 1.30, 1, 3, 1), (2, 'Breathe', 2.43, 2, 3, 1), (3, 'On the run', 3.30, 3, 3, 1), (4, 'Time', 6.53, 4, 3, 1), (5, 'The great gig in the sky', 4.15, 5, 3, 1), (6, 'Money', 6.30, 6, 3, 1), (7, 'Us and them', 7.49, 7, 3, 1), (8, 'Any colour you like', 3.24, 8, 3, 1), (9, 'Brain damage', 3.50, 9, 3, 1), (10, 'Eclipse', 1.45, 10, 3, 1), (11, 'Pigs on the wing i', 1.25, 1, 3, 2), (12, 'Dogs', 17.08, 2, 3, 2), (13, 'Pigs', 11.28, 3, 3, 2), (14, 'Sheep', 10.20, 4, 3, 2), (15, 'Pigs on the wing ii', 1.25, 5, 3, 2), (16, 'Watch that man', 4.25, 1, 5, 3), (17, 'Aladdin sane', 5.06, 2, 5, 3), (18, 'Drive in saturday', 4.33, 3, 5, 3), (19, 'Panic in detroit', 4.25, 4, 5, 3), (20, 'Cracked actor', 3.01, 5, 5, 3), (21, 'Time', 5.15, 6, 5, 3), (22, 'The prettiest star', 3.31, 7, 5, 3), (23, 'Lets spend the night together', 3.10, 8, 5, 3), (24, 'The jean genie', 4.07, 9, 5, 3), (25, 'Lady grinning soul', 3.54, 10, 5, 3), (26, 'Pray you catch me', 3.16, 1, 6, 4), (27, 'Hold up', 3.41, 2, 6, 4), (28, 'Dont hurt yourself', 3.54, 3, 6 , 4), (29, 'Sorry', 3.53, 4, 6, 4), (30, '6 inch', 4.20, 5, 6, 4), (31, 'Daddy lessons', 4.48, 6, 6, 4), (32, 'Love drought', 3.57, 7, 6, 4), (33, 'Sandcastles', 3.03, 8, 6, 4), (34, 'Forward', 1.19, 9, 6, 4), (35, 'Freedom', 4.50, 10, 6, 4), (36, 'All night', 5.22, 11, 6, 4), (37, 'Formation', 3.26, 12, 6, 4), (38, 'Infinite', 4.01, 1, 2, 5),
SELECT artisti.genere, MAX(registrazioni.titoloAlbum) AS titolo FROM ((brani INNER JOIN artisti ON brani.idArtista = artisti.idArtista) INNER JOIN registrazioni ON brani.idRegistrazione = registrazioni.idRegistrazione) WHERE artisti.nome='Beyonce' GROUP BY artisti.genere;