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