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