-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_tables.sql
68 lines (58 loc) · 1.84 KB
/
create_tables.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CREATE TABLE IF NOT EXISTS Artists (
ArtistID INTEGER PRIMARY KEY AUTO_INCREMENT,
ArtistName VARCHAR(255) NOT NULL,
DOB DATE,
Nationality VARCHAR(255)
);
CREATE TABLE IF NOT EXISTS Albums (
AlbumID INTEGER PRIMARY KEY AUTO_INCREMENT,
ArtistID INTEGER NOT NULL,
AlbumName VARCHAR(255) NOT NULL,
ReleaseDate DATE,
FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID)
);
CREATE TABLE IF NOT EXISTS Genres (
GenreID INTEGER PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL,
Origin VARCHAR(255)
);
CREATE TABLE IF NOT EXISTS RecordLabels (
LabelID INTEGER PRIMARY KEY AUTO_INCREMENT,
LabelName VARCHAR(255) NOT NULL,
PhoneNumber VARCHAR(255),
Address TEXT
);
CREATE TABLE IF NOT EXISTS Songs (
TrackID INTEGER PRIMARY KEY AUTO_INCREMENT,
Duration INT,
TrackName VARCHAR(255) NOT NULL,
GenreID INTEGER,
LabelID INTEGER,
AlbumID INTEGER,
ArtistID INTEGER,
FOREIGN KEY (GenreID) REFERENCES Genres(GenreID),
FOREIGN KEY (LabelID) REFERENCES RecordLabels(LabelID),
FOREIGN KEY (AlbumID) REFERENCES Albums(AlbumID),
FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID)
);
CREATE TABLE IF NOT EXISTS Compose (
ArtistID INTEGER,
TrackID INTEGER,
PRIMARY KEY (ArtistID, TrackID),
FOREIGN KEY (ArtistID) REFERENCES Artists(ArtistID),
FOREIGN KEY (TrackID) REFERENCES Songs(TrackID)
);
CREATE TABLE IF NOT EXISTS StreamingPlatforms (
PlatformID INTEGER PRIMARY KEY AUTO_INCREMENT,
PlatformName VARCHAR(255) NOT NULL,
TotalSubscribers INT,
SubscriptionFee DECIMAL(10, 2)
);
CREATE TABLE IF NOT EXISTS Streams (
PlatformID INTEGER,
TrackID INTEGER,
NumberOfStreams INT,
PRIMARY KEY (PlatformID, TrackID),
FOREIGN KEY (PlatformID) REFERENCES StreamingPlatforms(PlatformID),
FOREIGN KEY (TrackID) REFERENCES Songs(TrackID)
);