Commit | Line | Data |
243e940e |
1 | -- |
2 | -- Created by SQL::Translator::Producer::SQLite |
3814fdad |
3 | -- Created on Sat Mar 6 12:26:40 2010 |
0009fa49 |
4 | -- |
181b2261 |
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 | -- |
ebf846e8 |
38 | -- Table: employee |
887ce227 |
39 | -- |
ebf846e8 |
40 | CREATE TABLE employee ( |
41 | employee_id INTEGER PRIMARY KEY NOT NULL, |
42 | position integer NOT NULL, |
43 | group_id integer, |
44 | group_id_2 integer, |
9beded8a |
45 | group_id_3 integer, |
ebf846e8 |
46 | name varchar(100) |
887ce227 |
47 | ); |
48 | |
084a2c0a |
49 | -- |
50 | -- Table: encoded |
51 | -- |
52 | CREATE TABLE encoded ( |
53 | id INTEGER PRIMARY KEY NOT NULL, |
54 | encoded varchar(100) |
55 | ); |
ebf846e8 |
56 | |
9fcda149 |
57 | -- |
ebf846e8 |
58 | -- Table: event |
ab8481f5 |
59 | -- |
ebf846e8 |
60 | CREATE TABLE event ( |
ab8481f5 |
61 | id INTEGER PRIMARY KEY NOT NULL, |
ebf846e8 |
62 | starts_at datetime NOT NULL, |
a97fe7e0 |
63 | created_on timestamp NOT NULL, |
64 | varchar_date varchar(20), |
ff8a6e3b |
65 | varchar_datetime varchar(20), |
41308e82 |
66 | skip_inflation datetime, |
67 | ts_without_tz datetime |
ab8481f5 |
68 | ); |
69 | |
70 | -- |
ebf846e8 |
71 | -- Table: fourkeys |
9c2c91ea |
72 | -- |
ebf846e8 |
73 | CREATE TABLE fourkeys ( |
74 | foo integer NOT NULL, |
75 | bar integer NOT NULL, |
76 | hello integer NOT NULL, |
77 | goodbye integer NOT NULL, |
ff1234ad |
78 | sensors character(10) NOT NULL, |
79 | read_count integer, |
ebf846e8 |
80 | PRIMARY KEY (foo, bar, hello, goodbye) |
0009fa49 |
81 | ); |
82 | |
83 | -- |
ebf846e8 |
84 | -- Table: genre |
887ce227 |
85 | -- |
ebf846e8 |
86 | CREATE TABLE genre ( |
87310237 |
87 | genreid INTEGER PRIMARY KEY NOT NULL, |
56b73f83 |
88 | name varchar(100) NOT NULL |
9c2c91ea |
89 | ); |
90 | |
eb0bc670 |
91 | CREATE UNIQUE INDEX genre_name ON genre (name); |
ebf846e8 |
92 | |
93 | -- |
94 | -- Table: link |
95 | -- |
96 | CREATE TABLE link ( |
97 | id INTEGER PRIMARY KEY NOT NULL, |
98 | url varchar(100), |
99 | title varchar(100) |
100 | ); |
101 | |
9c2c91ea |
102 | -- |
41308e82 |
103 | -- Table: money_test |
104 | -- |
105 | CREATE TABLE money_test ( |
106 | id INTEGER PRIMARY KEY NOT NULL, |
107 | amount money |
108 | ); |
109 | |
110 | -- |
89034887 |
111 | -- Table: noprimarykey |
112 | -- |
113 | CREATE TABLE noprimarykey ( |
114 | foo integer NOT NULL, |
115 | bar integer NOT NULL, |
116 | baz integer NOT NULL |
117 | ); |
118 | |
eb0bc670 |
119 | CREATE UNIQUE INDEX foo_bar ON noprimarykey (foo, bar); |
ebf846e8 |
120 | |
89034887 |
121 | -- |
ebf846e8 |
122 | -- Table: onekey |
9c2c91ea |
123 | -- |
ebf846e8 |
124 | CREATE TABLE onekey ( |
125 | id INTEGER PRIMARY KEY NOT NULL, |
126 | artist integer NOT NULL, |
127 | cd integer NOT NULL |
9c2c91ea |
128 | ); |
129 | |
130 | -- |
ebf846e8 |
131 | -- Table: owners |
9c2c91ea |
132 | -- |
ebf846e8 |
133 | CREATE TABLE owners ( |
bed3a173 |
134 | id INTEGER PRIMARY KEY NOT NULL, |
ebf846e8 |
135 | name varchar(100) NOT NULL |
9c2c91ea |
136 | ); |
137 | |
138 | -- |
139 | -- Table: producer |
140 | -- |
141 | CREATE TABLE producer ( |
142 | producerid INTEGER PRIMARY KEY NOT NULL, |
8fcf21b3 |
143 | name varchar(100) NOT NULL |
887ce227 |
144 | ); |
145 | |
eb0bc670 |
146 | CREATE UNIQUE INDEX prod_name ON producer (name); |
ebf846e8 |
147 | |
9fcda149 |
148 | -- |
ebf846e8 |
149 | -- Table: self_ref |
9fcda149 |
150 | -- |
ebf846e8 |
151 | CREATE TABLE self_ref ( |
8fcf21b3 |
152 | id INTEGER PRIMARY KEY NOT NULL, |
ebf846e8 |
153 | name varchar(100) NOT NULL |
9fcda149 |
154 | ); |
155 | |
78060df8 |
156 | -- |
ebf846e8 |
157 | -- Table: sequence_test |
78060df8 |
158 | -- |
ebf846e8 |
159 | CREATE TABLE sequence_test ( |
160 | pkid1 integer NOT NULL, |
161 | pkid2 integer NOT NULL, |
162 | nonpkid integer NOT NULL, |
163 | name varchar(100), |
164 | PRIMARY KEY (pkid1, pkid2) |
78060df8 |
165 | ); |
166 | |
167 | -- |
ebf846e8 |
168 | -- Table: serialized |
78060df8 |
169 | -- |
ebf846e8 |
170 | CREATE TABLE serialized ( |
171 | id INTEGER PRIMARY KEY NOT NULL, |
172 | serialized text NOT NULL |
78060df8 |
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 | |
247 | -- |
248 | -- Table: forceforeign |
249 | -- |
250 | CREATE TABLE forceforeign ( |
251 | artist INTEGER PRIMARY KEY NOT NULL, |
252 | cd integer NOT NULL |
253 | ); |
254 | |
eb0bc670 |
255 | -- |
256 | -- Table: self_ref_alias |
257 | -- |
258 | CREATE TABLE self_ref_alias ( |
259 | self_ref integer NOT NULL, |
260 | alias integer NOT NULL, |
261 | PRIMARY KEY (self_ref, alias) |
78060df8 |
262 | ); |
263 | |
eb0bc670 |
264 | CREATE INDEX self_ref_alias_idx_alias ON self_ref_alias (alias); |
265 | |
266 | CREATE INDEX self_ref_alias_idx_self_ref ON self_ref_alias (self_ref); |
ebf846e8 |
267 | |
78060df8 |
268 | -- |
ebf846e8 |
269 | -- Table: track |
78060df8 |
270 | -- |
ebf846e8 |
271 | CREATE TABLE track ( |
272 | trackid INTEGER PRIMARY KEY NOT NULL, |
273 | cd integer NOT NULL, |
c1d7087d |
274 | position int NOT NULL, |
ebf846e8 |
275 | title varchar(100) NOT NULL, |
abc914bd |
276 | last_updated_on datetime, |
09451687 |
277 | last_updated_at datetime, |
c0678cfc |
278 | small_dt smalldatetime |
ebf846e8 |
279 | ); |
280 | |
eb0bc670 |
281 | CREATE INDEX track_idx_cd ON track (cd); |
084a2c0a |
282 | |
eb0bc670 |
283 | CREATE UNIQUE INDEX track_cd_position ON track (cd, position); |
084a2c0a |
284 | |
eb0bc670 |
285 | CREATE UNIQUE INDEX track_cd_title ON track (cd, title); |
ebf846e8 |
286 | |
287 | -- |
eb0bc670 |
288 | -- Table: cd |
ebf846e8 |
289 | -- |
eb0bc670 |
290 | CREATE TABLE cd ( |
291 | cdid INTEGER PRIMARY KEY NOT NULL, |
292 | artist integer NOT NULL, |
293 | title varchar(100) NOT NULL, |
294 | year varchar(100) NOT NULL, |
295 | genreid integer, |
296 | single_track integer |
297 | ); |
298 | |
299 | CREATE INDEX cd_idx_artist ON cd (artist); |
300 | |
301 | CREATE INDEX cd_idx_genreid ON cd (genreid); |
302 | |
303 | CREATE INDEX cd_idx_single_track ON cd (single_track); |
304 | |
305 | CREATE UNIQUE INDEX cd_artist_title ON cd (artist, title); |
306 | |
307 | -- |
308 | -- Table: collection_object |
309 | -- |
310 | CREATE TABLE collection_object ( |
311 | collection integer NOT NULL, |
312 | object integer NOT NULL, |
313 | PRIMARY KEY (collection, object) |
314 | ); |
315 | |
316 | CREATE INDEX collection_object_idx_collection ON collection_object (collection); |
317 | |
318 | CREATE INDEX collection_object_idx_object ON collection_object (object); |
319 | |
320 | -- |
321 | -- Table: lyrics |
322 | -- |
323 | CREATE TABLE lyrics ( |
324 | lyric_id INTEGER PRIMARY KEY NOT NULL, |
325 | track_id integer NOT NULL |
326 | ); |
327 | |
328 | CREATE INDEX lyrics_idx_track_id ON lyrics (track_id); |
329 | |
330 | -- |
331 | -- Table: cd_artwork |
332 | -- |
333 | CREATE TABLE cd_artwork ( |
334 | cd_id INTEGER PRIMARY KEY NOT NULL |
335 | ); |
336 | |
eb0bc670 |
337 | -- |
338 | -- Table: liner_notes |
339 | -- |
340 | CREATE TABLE liner_notes ( |
341 | liner_id INTEGER PRIMARY KEY NOT NULL, |
342 | notes varchar(100) NOT NULL |
343 | ); |
344 | |
eb0bc670 |
345 | -- |
346 | -- Table: lyric_versions |
347 | -- |
348 | CREATE TABLE lyric_versions ( |
78060df8 |
349 | id INTEGER PRIMARY KEY NOT NULL, |
eb0bc670 |
350 | lyric_id integer NOT NULL, |
351 | text varchar(100) NOT NULL |
ebf846e8 |
352 | ); |
353 | |
eb0bc670 |
354 | CREATE INDEX lyric_versions_idx_lyric_id ON lyric_versions (lyric_id); |
ebf846e8 |
355 | |
356 | -- |
eb0bc670 |
357 | -- Table: tags |
ebf846e8 |
358 | -- |
eb0bc670 |
359 | CREATE TABLE tags ( |
360 | tagid INTEGER PRIMARY KEY NOT NULL, |
361 | cd integer NOT NULL, |
362 | tag varchar(100) NOT NULL |
363 | ); |
364 | |
365 | CREATE INDEX tags_idx_cd ON tags (cd); |
366 | |
367 | -- |
368 | -- Table: cd_to_producer |
369 | -- |
370 | CREATE TABLE cd_to_producer ( |
371 | cd integer NOT NULL, |
372 | producer integer NOT NULL, |
373 | attribute integer, |
374 | PRIMARY KEY (cd, producer) |
ebf846e8 |
375 | ); |
376 | |
eb0bc670 |
377 | CREATE INDEX cd_to_producer_idx_cd ON cd_to_producer (cd); |
378 | |
379 | CREATE INDEX cd_to_producer_idx_producer ON cd_to_producer (producer); |
380 | |
381 | -- |
382 | -- Table: images |
383 | -- |
384 | CREATE TABLE images ( |
385 | id INTEGER PRIMARY KEY NOT NULL, |
386 | artwork_id integer NOT NULL, |
387 | name varchar(100) NOT NULL, |
388 | data blob |
389 | ); |
084a2c0a |
390 | |
eb0bc670 |
391 | CREATE INDEX images_idx_artwork_id ON images (artwork_id); |
ebf846e8 |
392 | |
393 | -- |
394 | -- Table: twokeys |
395 | -- |
396 | CREATE TABLE twokeys ( |
397 | artist integer NOT NULL, |
398 | cd integer NOT NULL, |
399 | PRIMARY KEY (artist, cd) |
400 | ); |
401 | |
eb0bc670 |
402 | CREATE INDEX twokeys_idx_artist ON twokeys (artist); |
ebf846e8 |
403 | |
404 | -- |
eb0bc670 |
405 | -- Table: artwork_to_artist |
ebf846e8 |
406 | -- |
eb0bc670 |
407 | CREATE TABLE artwork_to_artist ( |
408 | artwork_cd_id integer NOT NULL, |
409 | artist_id integer NOT NULL, |
410 | PRIMARY KEY (artwork_cd_id, artist_id) |
78060df8 |
411 | ); |
412 | |
eb0bc670 |
413 | CREATE INDEX artwork_to_artist_idx_artist_id ON artwork_to_artist (artist_id); |
414 | |
415 | CREATE INDEX artwork_to_artist_idx_artwork_cd_id ON artwork_to_artist (artwork_cd_id); |
416 | |
417 | -- |
418 | -- Table: fourkeys_to_twokeys |
419 | -- |
420 | CREATE TABLE fourkeys_to_twokeys ( |
421 | f_foo integer NOT NULL, |
422 | f_bar integer NOT NULL, |
423 | f_hello integer NOT NULL, |
424 | f_goodbye integer NOT NULL, |
425 | t_artist integer NOT NULL, |
426 | t_cd integer NOT NULL, |
427 | autopilot character NOT NULL, |
428 | pilot_sequence integer, |
429 | PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd) |
430 | ); |
431 | |
432 | 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); |
433 | |
434 | CREATE INDEX fourkeys_to_twokeys_idx_t_artist_t_cd ON fourkeys_to_twokeys (t_artist, t_cd); |
435 | |
0e80c4ca |
436 | -- |
084a2c0a |
437 | -- View: year2000cds |
0e80c4ca |
438 | -- |
084a2c0a |
439 | CREATE VIEW year2000cds AS |
181b2261 |
440 | SELECT cdid, artist, title, year, genreid, single_track FROM cd WHERE year = "2000" |