-
Notifications
You must be signed in to change notification settings - Fork 37
/
mysql.sql
40 lines (35 loc) · 1.09 KB
/
mysql.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
-- --------------------------------------------------------
--
-- Table structure for table `artists`
--
CREATE TABLE IF NOT EXISTS `artists` (
`id` char(16) NOT NULL DEFAULT '',
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `codes`
--
CREATE TABLE IF NOT EXISTS `codes` (
`code` int(7) NOT NULL,
`time` int(7) NOT NULL,
`track_id` char(16) NOT NULL,
PRIMARY KEY (`code`,`time`,`track_id`),
FOREIGN KEY (`track_id`) REFERENCES `tracks`(`id`) ON DELETE CASCADE
) DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `tracks`
--
CREATE TABLE IF NOT EXISTS `tracks` (
`id` char(16) NOT NULL,
`codever` char(4) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`artist_id` char(16) NOT NULL,
`length` int(5) NOT NULL,
`import_date` datetime NOT NULL,
PRIMARY KEY (`id`,`codever`),
FOREIGN KEY (`artist_id`) REFERENCES `artists`(`id`) ON DELETE CASCADE
) DEFAULT CHARSET=utf8;