-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
315 lines (294 loc) · 11.8 KB
/
schema.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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# IMSLP DB schema
#
# To avoid confusion, field names are same of mediawiki template param names;
# in some cases these are not ideal.
drop database imslp;
create database imslp character set utf8mb4 collate utf8mb4_unicode_ci;
use imslp;
# person: composer, performer, librettist, etc.
# May want a way to allow 2 people with same name
#
create table person (
id integer not null auto_increment,
first_name varchar(90) not null,
last_name varchar(90) not null,
alternate_names text,
birth_date text,
birth_place text,
born_year integer not null default 0,
born_month integer not null default 0,
born_day integer not null default 0,
death_date text,
death_place text,
died_year integer not null default 0,
died_month integer not null default 0,
died_day integer not null default 0,
flourished text,
is_composer tinyint not null default 0,
is_performer tinyint not null default 0,
nationality_ids JSON,
period_ids JSON,
picture text,
picture_caption text,
sex varchar(64) not null default'',
signature text,
unique(first_name, last_name),
primary key(id)
);
alter table person add fulltext index (first_name, last_name);
alter table person add index inat( (cast(nationality_ids->'$' as unsigned array)) );
alter table person add index iper( (cast(period_ids->'$' as unsigned array)) );
alter table person add index psex (sex);
create table nationality (
id integer not null auto_increment,
name varchar(190) not null,
unique(name),
primary key(id)
);
# classical, romantic etc.
#
create table period (
id integer not null auto_increment,
name varchar(190) not null,
unique(name),
primary key(id)
);
# actually license
#
create table copyright (
id integer not null auto_increment,
name varchar(190) not null,
unique(name),
primary key(id)
);
create table work (
id integer not null auto_increment,
redirect_id integer not null default 0,
title varchar(190) not null,
# from JSON key; includes title, opus, composer
composer_id integer not null,
alternative_title text,
attrib text,
authorities text,
average_duration text,
comments text,
dedication text,
discography text,
external_links text,
extra_information text,
first_performance text,
incipit text,
instrdetail text,
instrumentation text,
instrument_combo_ids JSON,
_key text,
# 'key' is a reserved word in SQL
language text,
language_ids JSON,
librettist text,
manuscript_sources text,
movements_header text,
ncrecordings text,
nonpd_eu tinyint not null default 0,
nonpd_us tinyint not null default 0,
number_of_movements_sections text,
opus_catalogue text,
period_id integer not null default 0,
related_works text,
sample_audio_file_name text,
# a representative recording of this work
sample_audio_file_id integer not null default 0,
searchkey text,
searchkey_amarec text,
searchkey_scores text,
tags text,
year_pub integer not null default 0,
# first pub if given, else year of comp
year_date_of_composition text,
year_of_composition integer not null default 0,
year_of_first_publication text,
work_title text,
work_type_ids JSON,
unique(title),
primary key(id)
);
alter table work add fulltext cindex (title, instrumentation);
alter table work add index wlang( (cast(language_ids->'$' as unsigned array)) );
alter table work add index wwt( (cast(work_type_ids->'$' as unsigned array)) );
alter table work add index wic( (cast(instrument_combo_ids->'$' as unsigned array)) );
alter table work add index wperiod (period_id);
create table publisher (
id integer not null auto_increment,
name text not null,
imprint text not null,
location text not null,
primary key(id)
);
# e.g. Viola and Piano, etc.
create table arrangement_target (
id integer not null auto_increment,
instruments varchar(190) not null,
unique(instruments),
primary key(id)
);
# a group of 1 or more score files (e.g. parts)
#
create table score_file_set (
id integer not null auto_increment,
work_id integer not null,
hier1 text,
# none, Parts, Arrangements and Transcriptions
hier2 text,
# none, Complete, Selections, the name of a movement
hier3 text,
# for Piano, for Piano (name of arranger)
amazon text,
arranger text,
arrangement_target_id integer not null default 0,
copyright_id integer not null default 0,
date_submitted text,
editor text,
engraver text,
file_tags text,
image_type text,
# Normal Scan, Typeset, Manuscript Scan
instrument_combo_ids JSON,
# if different from work (i.e. arrangement)
misc_notes text,
publisher_information text,
# the following populated if {{P was used
publisher_id integer not null default 0,
pub_date text,
pub_edition_number text,
pub_extra text,
pub_plate_number text,
pub_year integer not null default 0,
reprint text,
sample_audio_file_name text,
# for arrangements, a representative recording in same instrumentation
sample_audio_file_id integer not null default 0,
sample_filename text,
# an image file
scanner text,
sm_plus text,
thumb_filename text,
translator text,
uploader text,
primary key(id)
);
alter table score_file_set add index sfic( (cast(instrument_combo_ids->'$' as unsigned array)) );
alter table score_file_set add index sfwid(work_id);
# a single score file
create table score_file (
id integer not null auto_increment,
score_file_set_id integer not null default 0,
date_submitted text,
file_name text,
file_description text,
page_count text,
sample_filename text,
scanner text,
thumb_filename text,
uploader text,
primary key(id)
);
alter table score_file add index sfsfs(score_file_set_id);
create table audio_file_set (
id integer not null auto_increment,
work_id integer not null default 0,
hier1 text,
# none, Synthesized/MIDI
hier2 text,
# none, Complete, Selections, name of a mvt
hier3 text,
# for Piano, etc.
copyright_id integer not null default 0,
date_submitted text,
ensemble_id integer not null default 0,
instrument_combo_id integer not null default 0,
# populated for recordings of arrangements
misc_notes text,
performer_categories text,
performers text,
performer_role_ids JSON,
publisher_information text,
thumb_filename text,
uploader text,
primary key(id)
);
alter table audio_file_set add index afsw(work_id);
alter table audio_file_set add index ipr( (cast(performer_role_ids->'$' as unsigned array)) );
create table audio_file (
id integer not null auto_increment,
audio_file_set_id integer not null default 0,
date_submitted text,
file_name text,
file_description text,
primary key(id)
);
alter table audio_file add index afi(audio_file_set_id);
# the combination of a person and a musical role
# (instrument name(s) or conductor)
create table performer_role (
id integer not null auto_increment,
person_id integer not null,
role varchar(255) not null,
primary key(id)
);
alter table performer_role add index (person_id);
create table ensemble (
id integer not null auto_increment,
name varchar(190) not null,
alternate_names varchar(4096) not null default '',
born_year integer not null default 0,
died_year integer not null default 0,
nationality_id integer not null default 0,
# could make this an association table
period_id integer not null default 0,
# could make this an association table
picture varchar(255) not null default '',
type varchar(255) not null default '',
# orchestra, piano trio, etc.
# could make this a separate table
unique(name),
primary key(id)
);
create table work_type (
id integer not null auto_increment,
code varchar(190) not null,
name varchar(190) not null,
descendant_ids json,
nworks integer not null default 0,
unique(name),
unique(code),
primary key(id)
);
create table instrument (
id integer not null auto_increment,
code varchar(190) not null,
name varchar(190) not null,
ncombos integer not null default 0,
primary key(id)
);
create table instrument_combo (
id integer not null auto_increment,
instruments json,
# a structure consisting of 2 same-size lists:
# count => array of counts (always >0)
# ids => array of instrument ids
# this lets us search with member/overlap/contain
# on (sets of) instrument IDs
md5 varchar(64), # hash of instruments
nworks integer not null default 0,
nscores integer not null default 0,
unique(md5),
primary key(id)
);
alter table instrument_combo add index icinst( (cast(instruments->'$.id' as unsigned array)) );
create table language (
id integer not null auto_increment,
code varchar(190) not null,
name varchar(190) not null,
nworks integer not null default 0,
primary key(id)
);