· 7 years ago · Oct 22, 2018, 06:06 PM
1drop table if exists singers;
2drop table if exists albums;
3drop table if exists songs;
4
5PRAGMA foreign_keys = ON;
6
7create table singers ( sid Integer, s_name CHAR(30), origin CHAR(20), PRIMARY KEY(sid));
8
9create table albums (aid Integer, a_name CHAR(30), year INTEGER, rating Integer, sid INTEGER NOT NULL, PRIMARY KEY(aid), FOREIGN KEY (sid) REFERENCES singers);
10
11create table songs ( song_id Integer, song_name CHAR(30), duration INTEGER, aid INTEGER NOT NULL, PRIMARY KEY(song_id), FOREIGN KEY (aid) REFERENCES albums);
12
13INSERT INTO singers VALUES( 1, 'Taylor Swift', 'US');
14INSERT INTO singers VALUES( 2, 'Bryan Adams', 'Canada');
15INSERT INTO singers VALUES( 3, 'Drake', 'Canada');
16INSERT INTO singers VALUES( 4, 'Sia', 'Australia');
17
18INSERT INTO albums VALUES( 1, '1000 Forms of Fear', 2013 , 5, 4);
19INSERT INTO albums VALUES( 2, '18 till I Die', 1996, 4, 2);
20INSERT INTO albums VALUES( 3, 'Waking Up the Neighbours', 1991, 5, 2);
21INSERT INTO albums VALUES( 4, '1989', 2014, 4, 1);
22INSERT INTO albums VALUES( 5, 'Scorpion', 2018, 4, 3);
23
24
25INSERT INTO songs VALUES( 1, 'Chandelier', 245, 1);
26INSERT INTO songs VALUES( 2, "Elastic Heart", 255, 1);
27INSERT INTO songs VALUES( 3, "Let's Make a Night to Remember", 379, 2);
28INSERT INTO songs VALUES( 4, 'Everything I Do', 366, 3);
29INSERT INTO songs VALUES( 5, '18 Till I Die', 242, 2);
30INSERT INTO songs VALUES( 6, 'Blank Space', 231, 4);
31INSERT INTO songs VALUES( 7, 'In My Feelings', 217, 5);