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