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