-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_statements.py
83 lines (75 loc) · 1.54 KB
/
db_statements.py
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
73
74
75
76
77
78
79
80
81
82
83
CREATE_ARTISTS_TABLE = \
"""
CREATE TABLE IF NOT EXISTS artists (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
UNIQUE(name, type)
);
"""
CREATE_ARTIST_ALBUM_TABLE = \
"""
CREATE TABLE IF NOT EXISTS artist_album (
artist_id INTEGER,
album_id INTEGER,
UNIQUE(artist_id, album_id)
);
"""
CREATE_RAGAS_TABLE = \
"""
CREATE TABLE IF NOT EXISTS ragas (
id INTEGER PRIMARY KEY,
raga TEXT NOT NULL UNIQUE
);
"""
CREATE_TALAS_TABLE = \
"""
CREATE TABLE IF NOT EXISTS talas (
id INTEGER PRIMARY KEY,
tala TEXT NOT NULL UNIQUE
);
"""
CREATE_COMPOSERS_TABLE = \
"""
CREATE TABLE IF NOT EXISTS composers (
id INTEGER PRIMARY KEY,
composer TEXT NOT NULL UNIQUE
);
"""
CREATE_SONGS_TABLE = \
"""
CREATE TABLE IF NOT EXISTS songs (
id INTEGER PRIMARY KEY,
song TEXT NOT NULL,
raga_id INTEGER NOT NULL,
tala_id INTEGER,
composer_id INTEGER,
FOREIGN KEY(raga_id) REFERENCES ragas(id),
FOREIGN KEY(tala_id) REFERENCES talas(id),
FOREIGN KEY(composer_id) references composers(id),
UNIQUE(song, raga_id, tala_id, composer_id)
);
"""
CREATE_ALBUMS_TABLE = \
"""
CREATE TABLE IF NOT EXISTS albums (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
venue TEXT,
date TEXT,
info TEXT
);
"""
CREATE_TRACKS_TABLE = \
"""
CREATE TABLE IF NOT EXISTS tracks (
id INTEGER PRIMARY KEY,
album_id INTEGER,
album_index TEXT NOT NULL,
track_num INTEGER NOT NULL,
song_id INTEGER,
FOREIGN KEY(album_id) REFERENCES albums(id),
FOREIGN KEY(song_id) REFERENCES songs(id),
UNIQUE(album_id, album_index, song_id)
);
"""