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