Commit | Line | Data |
243e940e |
1 | -- |
2 | -- Created by SQL::Translator::Producer::SQLite |
3d98c75e |
3 | -- Created on Thu Nov 18 08:18:15 2010 |
0009fa49 |
4 | -- |
084a2c0a |
5 | |
0009fa49 |
6 | -- |
7 | -- Table: artist |
8 | -- |
9 | CREATE TABLE artist ( |
10 | artistid INTEGER PRIMARY KEY NOT NULL, |
39da2a2b |
11 | name varchar(100), |
8c7b6644 |
12 | rank integer NOT NULL DEFAULT 13, |
a0dd8679 |
13 | charfield char(10) |
0009fa49 |
14 | ); |
15 | |
0fd7e9a3 |
16 | CREATE INDEX artist_name_hookidx ON artist (name); |
17 | |
84f7e8a1 |
18 | CREATE UNIQUE INDEX artist_name ON artist (name); |
19 | |
e29e2b27 |
20 | CREATE UNIQUE INDEX u_nullable ON artist (charfield, rank); |
21 | |
0009fa49 |
22 | -- |
6ec7d1bb |
23 | -- Table: bindtype_test |
24 | -- |
25 | CREATE TABLE bindtype_test ( |
26 | id INTEGER PRIMARY KEY NOT NULL, |
27 | bytea blob, |
28 | blob blob, |
29 | clob clob |
30 | ); |
31 | |
6ec7d1bb |
32 | -- |
ebf846e8 |
33 | -- Table: collection |
0009fa49 |
34 | -- |
ebf846e8 |
35 | CREATE TABLE collection ( |
36 | collectionid INTEGER PRIMARY KEY NOT NULL, |
37 | name varchar(100) NOT NULL |
0009fa49 |
38 | ); |
39 | |
40 | -- |
084a2c0a |
41 | -- Table: encoded |
42 | -- |
43 | CREATE TABLE encoded ( |
44 | id INTEGER PRIMARY KEY NOT NULL, |
45 | encoded varchar(100) |
46 | ); |
ebf846e8 |
47 | |
9fcda149 |
48 | -- |
ebf846e8 |
49 | -- Table: event |
ab8481f5 |
50 | -- |
ebf846e8 |
51 | CREATE TABLE event ( |
ab8481f5 |
52 | id INTEGER PRIMARY KEY NOT NULL, |
c5827074 |
53 | starts_at date NOT NULL, |
a97fe7e0 |
54 | created_on timestamp NOT NULL, |
55 | varchar_date varchar(20), |
ff8a6e3b |
56 | varchar_datetime varchar(20), |
41308e82 |
57 | skip_inflation datetime, |
58 | ts_without_tz datetime |
ab8481f5 |
59 | ); |
60 | |
61 | -- |
823c91a1 |
62 | -- Table: file_columns |
63 | -- |
64 | CREATE TABLE file_columns ( |
65 | id INTEGER PRIMARY KEY NOT NULL, |
66 | file varchar(255) NOT NULL |
67 | ); |
68 | |
69 | -- |
ebf846e8 |
70 | -- Table: fourkeys |
9c2c91ea |
71 | -- |
ebf846e8 |
72 | CREATE TABLE fourkeys ( |
73 | foo integer NOT NULL, |
74 | bar integer NOT NULL, |
75 | hello integer NOT NULL, |
76 | goodbye integer NOT NULL, |
ff1234ad |
77 | sensors character(10) NOT NULL, |
78 | read_count integer, |
ebf846e8 |
79 | PRIMARY KEY (foo, bar, hello, goodbye) |
0009fa49 |
80 | ); |
81 | |
82 | -- |
ebf846e8 |
83 | -- Table: genre |
887ce227 |
84 | -- |
ebf846e8 |
85 | CREATE TABLE genre ( |
87310237 |
86 | genreid INTEGER PRIMARY KEY NOT NULL, |
56b73f83 |
87 | name varchar(100) NOT NULL |
9c2c91ea |
88 | ); |
89 | |
eb0bc670 |
90 | CREATE UNIQUE INDEX genre_name ON genre (name); |
ebf846e8 |
91 | |
92 | -- |
93 | -- Table: link |
94 | -- |
95 | CREATE TABLE link ( |
96 | id INTEGER PRIMARY KEY NOT NULL, |
97 | url varchar(100), |
98 | title varchar(100) |
99 | ); |
100 | |
9c2c91ea |
101 | -- |
41308e82 |
102 | -- Table: money_test |
103 | -- |
104 | CREATE TABLE money_test ( |
105 | id INTEGER PRIMARY KEY NOT NULL, |
106 | amount money |
107 | ); |
108 | |
109 | -- |
89034887 |
110 | -- Table: noprimarykey |
111 | -- |
112 | CREATE TABLE noprimarykey ( |
113 | foo integer NOT NULL, |
114 | bar integer NOT NULL, |
115 | baz integer NOT NULL |
116 | ); |
117 | |
eb0bc670 |
118 | CREATE UNIQUE INDEX foo_bar ON noprimarykey (foo, bar); |
ebf846e8 |
119 | |
89034887 |
120 | -- |
ebf846e8 |
121 | -- Table: onekey |
9c2c91ea |
122 | -- |
ebf846e8 |
123 | CREATE TABLE onekey ( |
124 | id INTEGER PRIMARY KEY NOT NULL, |
125 | artist integer NOT NULL, |
126 | cd integer NOT NULL |
9c2c91ea |
127 | ); |
128 | |
129 | -- |
ebf846e8 |
130 | -- Table: owners |
9c2c91ea |
131 | -- |
ebf846e8 |
132 | CREATE TABLE owners ( |
bed3a173 |
133 | id INTEGER PRIMARY KEY NOT NULL, |
ebf846e8 |
134 | name varchar(100) NOT NULL |
9c2c91ea |
135 | ); |
136 | |
137 | -- |
138 | -- Table: producer |
139 | -- |
140 | CREATE TABLE producer ( |
141 | producerid INTEGER PRIMARY KEY NOT NULL, |
8fcf21b3 |
142 | name varchar(100) NOT NULL |
887ce227 |
143 | ); |
144 | |
eb0bc670 |
145 | CREATE UNIQUE INDEX prod_name ON producer (name); |
ebf846e8 |
146 | |
9fcda149 |
147 | -- |
ebf846e8 |
148 | -- Table: self_ref |
9fcda149 |
149 | -- |
ebf846e8 |
150 | CREATE TABLE self_ref ( |
8fcf21b3 |
151 | id INTEGER PRIMARY KEY NOT NULL, |
ebf846e8 |
152 | name varchar(100) NOT NULL |
9fcda149 |
153 | ); |
154 | |
78060df8 |
155 | -- |
ebf846e8 |
156 | -- Table: sequence_test |
78060df8 |
157 | -- |
ebf846e8 |
158 | CREATE TABLE sequence_test ( |
159 | pkid1 integer NOT NULL, |
160 | pkid2 integer NOT NULL, |
161 | nonpkid integer NOT NULL, |
162 | name varchar(100), |
163 | PRIMARY KEY (pkid1, pkid2) |
78060df8 |
164 | ); |
165 | |
166 | -- |
ebf846e8 |
167 | -- Table: serialized |
78060df8 |
168 | -- |
ebf846e8 |
169 | CREATE TABLE serialized ( |
170 | id INTEGER PRIMARY KEY NOT NULL, |
171 | serialized text NOT NULL |
78060df8 |
172 | ); |
173 | |
174 | -- |
4d4dc518 |
175 | -- Table: timestamp_primary_key_test |
176 | -- |
177 | CREATE TABLE timestamp_primary_key_test ( |
178 | id timestamp NOT NULL DEFAULT current_timestamp, |
179 | PRIMARY KEY (id) |
180 | ); |
181 | |
182 | -- |
eb0bc670 |
183 | -- Table: treelike |
78060df8 |
184 | -- |
eb0bc670 |
185 | CREATE TABLE treelike ( |
186 | id INTEGER PRIMARY KEY NOT NULL, |
187 | parent integer, |
188 | name varchar(100) NOT NULL |
189 | ); |
190 | |
191 | CREATE INDEX treelike_idx_parent ON treelike (parent); |
192 | |
193 | -- |
194 | -- Table: twokeytreelike |
195 | -- |
196 | CREATE TABLE twokeytreelike ( |
197 | id1 integer NOT NULL, |
198 | id2 integer NOT NULL, |
199 | parent1 integer NOT NULL, |
200 | parent2 integer NOT NULL, |
201 | name varchar(100) NOT NULL, |
202 | PRIMARY KEY (id1, id2) |
203 | ); |
204 | |
205 | CREATE INDEX twokeytreelike_idx_parent1_parent2 ON twokeytreelike (parent1, parent2); |
206 | |
207 | CREATE UNIQUE INDEX tktlnameunique ON twokeytreelike (name); |
208 | |
209 | -- |
210 | -- Table: typed_object |
211 | -- |
212 | CREATE TABLE typed_object ( |
213 | objectid INTEGER PRIMARY KEY NOT NULL, |
214 | type varchar(100) NOT NULL, |
215 | value varchar(100) NOT NULL |
216 | ); |
217 | |
218 | -- |
219 | -- Table: artist_undirected_map |
220 | -- |
221 | CREATE TABLE artist_undirected_map ( |
222 | id1 integer NOT NULL, |
223 | id2 integer NOT NULL, |
224 | PRIMARY KEY (id1, id2) |
225 | ); |
226 | |
227 | CREATE INDEX artist_undirected_map_idx_id1 ON artist_undirected_map (id1); |
228 | |
229 | CREATE INDEX artist_undirected_map_idx_id2 ON artist_undirected_map (id2); |
230 | |
231 | -- |
232 | -- Table: bookmark |
233 | -- |
234 | CREATE TABLE bookmark ( |
235 | id INTEGER PRIMARY KEY NOT NULL, |
41308e82 |
236 | link integer |
eb0bc670 |
237 | ); |
238 | |
239 | CREATE INDEX bookmark_idx_link ON bookmark (link); |
240 | |
241 | -- |
242 | -- Table: books |
243 | -- |
244 | CREATE TABLE books ( |
245 | id INTEGER PRIMARY KEY NOT NULL, |
246 | source varchar(100) NOT NULL, |
247 | owner integer NOT NULL, |
248 | title varchar(100) NOT NULL, |
249 | price integer |
250 | ); |
251 | |
252 | CREATE INDEX books_idx_owner ON books (owner); |
253 | |
8c7b6644 |
254 | CREATE UNIQUE INDEX books_title ON books (title); |
255 | |
eb0bc670 |
256 | -- |
68888c09 |
257 | -- Table: employee |
258 | -- |
259 | CREATE TABLE employee ( |
260 | employee_id INTEGER PRIMARY KEY NOT NULL, |
261 | position integer NOT NULL, |
262 | group_id integer, |
263 | group_id_2 integer, |
264 | group_id_3 integer, |
265 | name varchar(100), |
266 | encoded integer |
267 | ); |
268 | |
269 | CREATE INDEX employee_idx_encoded ON employee (encoded); |
270 | |
271 | -- |
eb0bc670 |
272 | -- Table: forceforeign |
273 | -- |
274 | CREATE TABLE forceforeign ( |
275 | artist INTEGER PRIMARY KEY NOT NULL, |
276 | cd integer NOT NULL |
277 | ); |
278 | |
eb0bc670 |
279 | -- |
280 | -- Table: self_ref_alias |
281 | -- |
282 | CREATE TABLE self_ref_alias ( |
283 | self_ref integer NOT NULL, |
284 | alias integer NOT NULL, |
285 | PRIMARY KEY (self_ref, alias) |
78060df8 |
286 | ); |
287 | |
eb0bc670 |
288 | CREATE INDEX self_ref_alias_idx_alias ON self_ref_alias (alias); |
289 | |
290 | CREATE INDEX self_ref_alias_idx_self_ref ON self_ref_alias (self_ref); |
ebf846e8 |
291 | |
78060df8 |
292 | -- |
ebf846e8 |
293 | -- Table: track |
78060df8 |
294 | -- |
ebf846e8 |
295 | CREATE TABLE track ( |
296 | trackid INTEGER PRIMARY KEY NOT NULL, |
297 | cd integer NOT NULL, |
c1d7087d |
298 | position int NOT NULL, |
ebf846e8 |
299 | title varchar(100) NOT NULL, |
abc914bd |
300 | last_updated_on datetime, |
3d98c75e |
301 | last_updated_at datetime |
ebf846e8 |
302 | ); |
303 | |
eb0bc670 |
304 | CREATE INDEX track_idx_cd ON track (cd); |
084a2c0a |
305 | |
eb0bc670 |
306 | CREATE UNIQUE INDEX track_cd_position ON track (cd, position); |
084a2c0a |
307 | |
eb0bc670 |
308 | CREATE UNIQUE INDEX track_cd_title ON track (cd, title); |
ebf846e8 |
309 | |
310 | -- |
eb0bc670 |
311 | -- Table: cd |
ebf846e8 |
312 | -- |
eb0bc670 |
313 | CREATE TABLE cd ( |
314 | cdid INTEGER PRIMARY KEY NOT NULL, |
315 | artist integer NOT NULL, |
316 | title varchar(100) NOT NULL, |
317 | year varchar(100) NOT NULL, |
318 | genreid integer, |
319 | single_track integer |
320 | ); |
321 | |
322 | CREATE INDEX cd_idx_artist ON cd (artist); |
323 | |
324 | CREATE INDEX cd_idx_genreid ON cd (genreid); |
325 | |
326 | CREATE INDEX cd_idx_single_track ON cd (single_track); |
327 | |
328 | CREATE UNIQUE INDEX cd_artist_title ON cd (artist, title); |
329 | |
330 | -- |
331 | -- Table: collection_object |
332 | -- |
333 | CREATE TABLE collection_object ( |
334 | collection integer NOT NULL, |
335 | object integer NOT NULL, |
336 | PRIMARY KEY (collection, object) |
337 | ); |
338 | |
339 | CREATE INDEX collection_object_idx_collection ON collection_object (collection); |
340 | |
341 | CREATE INDEX collection_object_idx_object ON collection_object (object); |
342 | |
343 | -- |
344 | -- Table: lyrics |
345 | -- |
346 | CREATE TABLE lyrics ( |
347 | lyric_id INTEGER PRIMARY KEY NOT NULL, |
348 | track_id integer NOT NULL |
349 | ); |
350 | |
351 | CREATE INDEX lyrics_idx_track_id ON lyrics (track_id); |
352 | |
353 | -- |
354 | -- Table: cd_artwork |
355 | -- |
356 | CREATE TABLE cd_artwork ( |
357 | cd_id INTEGER PRIMARY KEY NOT NULL |
358 | ); |
359 | |
eb0bc670 |
360 | -- |
361 | -- Table: liner_notes |
362 | -- |
363 | CREATE TABLE liner_notes ( |
364 | liner_id INTEGER PRIMARY KEY NOT NULL, |
365 | notes varchar(100) NOT NULL |
366 | ); |
367 | |
eb0bc670 |
368 | -- |
369 | -- Table: lyric_versions |
370 | -- |
371 | CREATE TABLE lyric_versions ( |
78060df8 |
372 | id INTEGER PRIMARY KEY NOT NULL, |
eb0bc670 |
373 | lyric_id integer NOT NULL, |
374 | text varchar(100) NOT NULL |
ebf846e8 |
375 | ); |
376 | |
eb0bc670 |
377 | CREATE INDEX lyric_versions_idx_lyric_id ON lyric_versions (lyric_id); |
ebf846e8 |
378 | |
379 | -- |
eb0bc670 |
380 | -- Table: tags |
ebf846e8 |
381 | -- |
eb0bc670 |
382 | CREATE TABLE tags ( |
383 | tagid INTEGER PRIMARY KEY NOT NULL, |
384 | cd integer NOT NULL, |
385 | tag varchar(100) NOT NULL |
386 | ); |
387 | |
388 | CREATE INDEX tags_idx_cd ON tags (cd); |
389 | |
84f7e8a1 |
390 | CREATE UNIQUE INDEX tagid_cd ON tags (tagid, cd); |
391 | |
392 | CREATE UNIQUE INDEX tagid_cd_tag ON tags (tagid, cd, tag); |
393 | |
394 | CREATE UNIQUE INDEX tags_tagid_tag ON tags (tagid, tag); |
395 | |
396 | CREATE UNIQUE INDEX tags_tagid_tag_cd ON tags (tagid, tag, cd); |
397 | |
eb0bc670 |
398 | -- |
399 | -- Table: cd_to_producer |
400 | -- |
401 | CREATE TABLE cd_to_producer ( |
402 | cd integer NOT NULL, |
403 | producer integer NOT NULL, |
404 | attribute integer, |
405 | PRIMARY KEY (cd, producer) |
ebf846e8 |
406 | ); |
407 | |
eb0bc670 |
408 | CREATE INDEX cd_to_producer_idx_cd ON cd_to_producer (cd); |
409 | |
410 | CREATE INDEX cd_to_producer_idx_producer ON cd_to_producer (producer); |
411 | |
412 | -- |
413 | -- Table: images |
414 | -- |
415 | CREATE TABLE images ( |
416 | id INTEGER PRIMARY KEY NOT NULL, |
417 | artwork_id integer NOT NULL, |
418 | name varchar(100) NOT NULL, |
419 | data blob |
420 | ); |
084a2c0a |
421 | |
eb0bc670 |
422 | CREATE INDEX images_idx_artwork_id ON images (artwork_id); |
ebf846e8 |
423 | |
424 | -- |
425 | -- Table: twokeys |
426 | -- |
427 | CREATE TABLE twokeys ( |
428 | artist integer NOT NULL, |
429 | cd integer NOT NULL, |
430 | PRIMARY KEY (artist, cd) |
431 | ); |
432 | |
eb0bc670 |
433 | CREATE INDEX twokeys_idx_artist ON twokeys (artist); |
ebf846e8 |
434 | |
435 | -- |
eb0bc670 |
436 | -- Table: artwork_to_artist |
ebf846e8 |
437 | -- |
eb0bc670 |
438 | CREATE TABLE artwork_to_artist ( |
439 | artwork_cd_id integer NOT NULL, |
440 | artist_id integer NOT NULL, |
441 | PRIMARY KEY (artwork_cd_id, artist_id) |
78060df8 |
442 | ); |
443 | |
eb0bc670 |
444 | CREATE INDEX artwork_to_artist_idx_artist_id ON artwork_to_artist (artist_id); |
445 | |
446 | CREATE INDEX artwork_to_artist_idx_artwork_cd_id ON artwork_to_artist (artwork_cd_id); |
447 | |
448 | -- |
449 | -- Table: fourkeys_to_twokeys |
450 | -- |
451 | CREATE TABLE fourkeys_to_twokeys ( |
452 | f_foo integer NOT NULL, |
453 | f_bar integer NOT NULL, |
454 | f_hello integer NOT NULL, |
455 | f_goodbye integer NOT NULL, |
456 | t_artist integer NOT NULL, |
457 | t_cd integer NOT NULL, |
458 | autopilot character NOT NULL, |
459 | pilot_sequence integer, |
460 | PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd) |
461 | ); |
462 | |
463 | CREATE INDEX fourkeys_to_twokeys_idx_f_foo_f_bar_f_hello_f_goodbye ON fourkeys_to_twokeys (f_foo, f_bar, f_hello, f_goodbye); |
464 | |
465 | CREATE INDEX fourkeys_to_twokeys_idx_t_artist_t_cd ON fourkeys_to_twokeys (t_artist, t_cd); |
466 | |
0e80c4ca |
467 | -- |
084a2c0a |
468 | -- View: year2000cds |
0e80c4ca |
469 | -- |
084a2c0a |
470 | CREATE VIEW year2000cds AS |
8c7b6644 |
471 | SELECT cdid, artist, title, year, genreid, single_track FROM cd WHERE year = "2000"; |