-
Notifications
You must be signed in to change notification settings - Fork 5
/
dbquery.txt
45 lines (42 loc) · 1.04 KB
/
dbquery.txt
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
CREATE TABLE album (
album_id INT NOT NULL,
judul CHAR(64) NOT NULL,
penyanyi CHAR(128) NOT NULL,
total_duration INT NOT NULL,
image_path CHAR(255) NOT NULL,
tanggal_terbit DATE NOT NULL,
genre CHAR(64),
PRIMARY KEY(album_id)
);
CREATE TABLE song (
song_id INT NOT NULL,
judul CHAR(64) NOT NULL,
penyanyi CHAR(128),
tanggal_terbit DATE NOT NULL,
genre CHAR(64),
duration INT NOT NULL,
audio_path CHAR(255) NOT NULL,
image_path CHAR(255),
album_id INT,
PRIMARY KEY(song_id),
CONSTRAINT fk_songalbum
FOREIGN KEY(album_id)
REFERENCES album(album_id)
);
CREATE TABLE users (
user_id INT NOT NULL,
email CHAR(255) NOT NULL,
password CHAR(255) NOT NULL,
username CHAR(255) NOT NULL,
isAdmin BOOLEAN NOT NULL,
PRIMARY KEY(user_id)
);
CREATE TABLE sessions (
session_id CHAR(255) NOT NULL,
user_id INT NOT NULL,
exp CHAR(255) NOT NULL,
PRIMARY KEY(session_id),
CONSTRAINT fk_usersess
FOREIGN KEY(user_id)
REFERENCES users(user_id)
);