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