3 CREATE DATABASE `kworship` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
5 USE DATABASE `kworship`;
9 CREATE TABLE CssStyleSheet (
10 `id` INT NOT NULL AUTO_INCREMENT,
14 CREATE TABLE CssRule (
15 `id` INT NOT NULL AUTO_INCREMENT,
16 `style_sheet_id` INT NOT NULL,
18 UNIQUE (`style_sheet_id`),
19 FOREIGN KEY (`style_sheet_id`) REFERENCES CssStyleSheet (`id`)
20 ON UPDATE CASCADE ON DELETE RESTRICT
23 CREATE TABLE CssRuleCriteriaScope (
24 `rule_id` INT NOT NULL,
26 `type` VARCHAR(32) NULL,
27 `name` VARCHAR(32) NULL,
28 PRIMARY KEY (`rule_id`, `order`),
29 FOREIGN KEY (`rule_id`) REFERENCES CssRule (`id`)
30 ON UPDATE CASCADE ON DELETE RESTRICT
33 CREATE TABLE CssRuleCriteriaClass (
34 `rule_id` INT NOT NULL,
35 `class` VARCHAR(64) NOT NULL,
36 PRIMARY KEY (`rule_id`, `class`),
37 FOREIGN KEY (`rule_id`) REFERENCES CssRule (`id`)
38 ON UPDATE CASCADE ON DELETE RESTRICT
41 CREATE TABLE CssRuleUsedClass (
42 `rule_id` INT NOT NULL,
43 `class` VARCHAR(64) NOT NULL,
44 PRIMARY KEY (`rule_id`, `class`),
45 FOREIGN KEY (`rule_id`) REFERENCES CssRule (`id`)
46 ON UPDATE CASCADE ON DELETE RESTRICT
49 CREATE TABLE CssRuleStyle (
50 `rule_id` INT NOT NULL,
51 `style` VARCHAR(64) NOT NULL,
52 `value` VARCHAR(256) NOT NULL,
53 PRIMARY KEY (`rule_id`, `style`),
54 FOREIGN KEY (`rule_id`) REFERENCES CssRule (`id`)
55 ON UPDATE CASCADE ON DELETE RESTRICT
61 `id` INT NOT NULL AUTO_INCREMENT,
62 `name` VARCHAR(128) NOT NULL,
63 `alternate_name` VARCHAR(128) NOT NULL,
64 `css_style_sheet_id` INT NULL,
67 UNIQUE (`css_style_sheet_id`),
68 FOREIGN KEY (`css_style_sheet_id`) REFERENCES CssStyleSheet (`id`)
69 ON UPDATE CASCADE ON DELETE CASCADE
72 CREATE TABLE SongBook (
73 `id` INT NOT NULL AUTO_INCREMENT,
74 `abreviation` VARCHAR(8) NOT NULL,
75 `name` VARCHAR(128) NOT NULL,
76 `description` MEDIUMTEXT NULL,
78 UNIQUE (`abreviation`)
81 CREATE TABLE SongVersion (
82 `id` INT NOT NULL AUTO_INCREMENT,
83 `song_id` INT NOT NULL,
84 `name` VARCHAR(128) NULL,
85 `css_style_sheet_id` INT NULL,
86 `writer` VARCHAR(128) NULL,
87 `copyright` VARCHAR(128) NULL,
88 `lyrics` TEXT NOT NULL
90 UNIQUE (`song_id`, `name`),
91 FOREIGN KEY (`song_id`) REFERENCES Song (`id`)
92 ON UPDATE CASCADE ON DELETE RESTRICT,
93 FOREIGN KEY (`css_style_sheet_id`) REFERENCES CssStyleSheet (`id`)
94 ON UPDATE CASCADE ON DELETE CASCADE
97 CREATE TABLE SongBookSong (
98 `book_id` INT NOT NULL,
99 `book_number` INT NOT NULL,
100 `version_id` INT NOT NULL,
101 PRIMARY KEY (`book_id`, `book_number`),
102 FOREIGN KEY (`book_id`) REFERENCES SongBook (`id`)
103 ON UPDATE CASCADE ON DELETE RESTRICT,
104 FOREIGN KEY (`version_id`) REFERENCES SongVersion (`id`)
105 ON UPDATE CASCADE ON DELETE RESTRICT
108 CREATE TABLE SongMedia (
109 `id` INT NOT NULL AUTO_INCREMENT,
110 `version_id` INT NOT NULL,
111 `url` VARCHAR(128) NOT NULL,
112 `audio_use` BOOLEAN NOT NULL DEFAULT FALSE,
113 `audio_volume` FLOAT NOT NULL DEFAULT 1.0,
114 `video_use` BOOLEAN NOT NULL DEFAULT FALSE,
116 FOREIGN KEY (`version_id`) REFERENCES SongVersion (`id`)
117 ON UPDATE CASCADE ON DELETE RESTRICT
121 /* Populate the database with some data */