-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmh.sql
39 lines (34 loc) · 1.1 KB
/
mh.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--this SQL file is based off of this ERD table: https://www.draw.io/#G0Bw-gU8RWcRQ-VXpqVjVpTkk4Y3M
DELETE FROM Artist;
DELETE FROM Album;
DELETE FROM Song;
DELETE FROM SongAlbum;
Drop Table if Exists Song;
Drop Table if Exists SongAlbum;
Drop Table if Exists Album;
Drop Table if Exists Artist;
Create Table Album (
AlbumId Integer not null primary key Autoincrement,
ArtistId integer not null,
FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)
);
Create Table Artist (
ArtistId Integer not null primary key Autoincrement,
Name text not null,
Albums text not null
);
Create Table SongAlbum (
SongAlbum Integer not null primary key Autoincrement,
ArtistId integer not null,
AlbumId integer not null,
FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId),
FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)
);
Create Table Song (
SongId Integer not null primary key Autoincrement,
nameofsong text not null,
length integer not null,
albumid integer not null,
genre text not null,
Foreign Key (albumid) REFERENCES Album(AlbumId)
);