-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit_table.sql
More file actions
72 lines (69 loc) · 1.44 KB
/
init_table.sql
File metadata and controls
72 lines (69 loc) · 1.44 KB
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
67
68
69
70
71
72
-- CMPUT 291 - Fall 2022 (Davood Rafiei)
drop table if exists perform;
drop table if exists artists;
drop table if exists plinclude;
drop table if exists playlists;
drop table if exists listen;
drop table if exists sessions;
drop table if exists songs;
drop table if exists users;
PRAGMA foreign_keys = ON;
create table users (
uid char(4),
name text,
pwd text,
primary key (uid)
);
create table songs (
sid int,
title text,
duration int,
primary key (sid)
);
create table sessions (
uid char(4),
sno int,
start date,
end date,
primary key (uid,sno),
foreign key (uid) references users
on delete cascade
);
create table listen (
uid char(4),
sno int,
sid int,
cnt real,
primary key (uid,sno,sid),
foreign key (uid,sno) references sessions,
foreign key (sid) references songs
);
create table playlists (
pid int,
title text,
uid char(4),
primary key (pid),
foreign key (uid) references users
);
create table plinclude (
pid int,
sid int,
sorder int,
primary key (pid,sid),
foreign key (pid) references playlists,
foreign key (sid) references songs
);
create table artists (
aid char(4),
name text,
nationality text,
pwd text,
primary key (aid)
);
create table perform (
aid char(4),
sid int,
primary key (aid,sid),
foreign key (aid) references artists,
foreign key (sid) references songs
);