Add tests for virtual view
[dbsrgits/DBIx-Class.git] / t / lib / sqlite.sql
CommitLineData
0009fa49 1--
2-- Created by SQL::Translator::Producer::SQLite
1ee9aa72 3-- Created on Thu Feb 19 22:09:32 2009
0009fa49 4--
0009fa49 5
0009fa49 6
084a2c0a 7BEGIN TRANSACTION;
8
0009fa49 9--
10-- Table: artist
11--
12CREATE TABLE artist (
13 artistid INTEGER PRIMARY KEY NOT NULL,
39da2a2b 14 name varchar(100),
a0dd8679 15 rank integer NOT NULL DEFAULT '13',
16 charfield char(10)
0009fa49 17);
18
19--
ebf846e8 20-- Table: artist_undirected_map
9c2c91ea 21--
ebf846e8 22CREATE TABLE artist_undirected_map (
9c2c91ea 23 id1 integer NOT NULL,
24 id2 integer NOT NULL,
9c2c91ea 25 PRIMARY KEY (id1, id2)
26);
27
ebf846e8 28CREATE INDEX artist_undirected_map_idx_id1_ ON artist_undirected_map (id1);
084a2c0a 29
ebf846e8 30CREATE INDEX artist_undirected_map_idx_id2_ ON artist_undirected_map (id2);
31
9c2c91ea 32--
4f6386b0 33-- Table: cd_artwork
34--
35CREATE TABLE cd_artwork (
36 cd_id INTEGER PRIMARY KEY NOT NULL
37);
38
39CREATE INDEX cd_artwork_idx_cd_id_cd_artwor ON cd_artwork (cd_id);
40
41--
6ec7d1bb 42-- Table: bindtype_test
43--
44CREATE TABLE bindtype_test (
45 id INTEGER PRIMARY KEY NOT NULL,
46 bytea blob,
47 blob blob,
48 clob clob
49);
50
6ec7d1bb 51--
ebf846e8 52-- Table: bookmark
3bd6e3e0 53--
ebf846e8 54CREATE TABLE bookmark (
55 id INTEGER PRIMARY KEY NOT NULL,
56 link integer NOT NULL
3bd6e3e0 57);
58
ebf846e8 59CREATE INDEX bookmark_idx_link_bookmark ON bookmark (link);
60
3bd6e3e0 61--
ebf846e8 62-- Table: books
0009fa49 63--
ebf846e8 64CREATE TABLE books (
65 id INTEGER PRIMARY KEY NOT NULL,
66 source varchar(100) NOT NULL,
67 owner integer NOT NULL,
cda5e082 68 title varchar(100) NOT NULL,
69 price integer
0009fa49 70);
71
72--
0009fa49 73-- Table: cd
74--
75CREATE TABLE cd (
76 cdid INTEGER PRIMARY KEY NOT NULL,
77 artist integer NOT NULL,
8fcf21b3 78 title varchar(100) NOT NULL,
370f2ba2 79 year varchar(100) NOT NULL,
a1cb5921 80 genreid integer,
81 single_track integer
370f2ba2 82);
83
ebf846e8 84CREATE INDEX cd_idx_artist_cd ON cd (artist);
084a2c0a 85
ebf846e8 86CREATE INDEX cd_idx_genreid_cd ON cd (genreid);
084a2c0a 87
a1cb5921 88CREATE INDEX cd_idx_single_track_cd ON cd (single_track);
084a2c0a 89
ebf846e8 90CREATE UNIQUE INDEX cd_artist_title_cd ON cd (artist, title);
91
370f2ba2 92--
ebf846e8 93-- Table: cd_to_producer
370f2ba2 94--
ebf846e8 95CREATE TABLE cd_to_producer (
96 cd integer NOT NULL,
97 producer integer NOT NULL,
98 PRIMARY KEY (cd, producer)
0009fa49 99);
100
ebf846e8 101CREATE INDEX cd_to_producer_idx_cd_cd_to_pr ON cd_to_producer (cd);
084a2c0a 102
ebf846e8 103CREATE INDEX cd_to_producer_idx_producer_cd ON cd_to_producer (producer);
104
0009fa49 105--
ebf846e8 106-- Table: collection
0009fa49 107--
ebf846e8 108CREATE TABLE collection (
109 collectionid INTEGER PRIMARY KEY NOT NULL,
110 name varchar(100) NOT NULL
0009fa49 111);
112
113--
ebf846e8 114-- Table: collection_object
0009fa49 115--
ebf846e8 116CREATE TABLE collection_object (
117 collection integer NOT NULL,
118 object integer NOT NULL,
119 PRIMARY KEY (collection, object)
0009fa49 120);
121
ebf846e8 122CREATE INDEX collection_object_idx_collection_collection_obj ON collection_object (collection);
084a2c0a 123
ebf846e8 124CREATE INDEX collection_object_idx_object_c ON collection_object (object);
125
0009fa49 126--
ebf846e8 127-- Table: employee
887ce227 128--
ebf846e8 129CREATE TABLE employee (
130 employee_id INTEGER PRIMARY KEY NOT NULL,
131 position integer NOT NULL,
132 group_id integer,
133 group_id_2 integer,
134 name varchar(100)
887ce227 135);
136
084a2c0a 137--
138-- Table: encoded
139--
140CREATE TABLE encoded (
141 id INTEGER PRIMARY KEY NOT NULL,
142 encoded varchar(100)
143);
ebf846e8 144
9fcda149 145--
ebf846e8 146-- Table: event
ab8481f5 147--
ebf846e8 148CREATE TABLE event (
ab8481f5 149 id INTEGER PRIMARY KEY NOT NULL,
ebf846e8 150 starts_at datetime NOT NULL,
a97fe7e0 151 created_on timestamp NOT NULL,
152 varchar_date varchar(20),
ff8a6e3b 153 varchar_datetime varchar(20),
a0dd8679 154 skip_inflation datetime
ab8481f5 155);
156
157--
4740bdb7 158-- Table: file_columns
159--
160CREATE TABLE file_columns (
161 id INTEGER PRIMARY KEY NOT NULL,
ebf846e8 162 file varchar(255) NOT NULL
4740bdb7 163);
164
165--
ebf846e8 166-- Table: forceforeign
77211009 167--
ebf846e8 168CREATE TABLE forceforeign (
169 artist INTEGER PRIMARY KEY NOT NULL,
170 cd integer NOT NULL
77211009 171);
172
ebf846e8 173CREATE INDEX forceforeign_idx_artist_forcef ON forceforeign (artist);
174
77211009 175--
ebf846e8 176-- Table: fourkeys
9c2c91ea 177--
ebf846e8 178CREATE TABLE fourkeys (
179 foo integer NOT NULL,
180 bar integer NOT NULL,
181 hello integer NOT NULL,
182 goodbye integer NOT NULL,
183 sensors character NOT NULL,
184 PRIMARY KEY (foo, bar, hello, goodbye)
0009fa49 185);
186
187--
ebf846e8 188-- Table: fourkeys_to_twokeys
0009fa49 189--
ebf846e8 190CREATE TABLE fourkeys_to_twokeys (
191 f_foo integer NOT NULL,
192 f_bar integer NOT NULL,
193 f_hello integer NOT NULL,
194 f_goodbye integer NOT NULL,
195 t_artist integer NOT NULL,
196 t_cd integer NOT NULL,
197 autopilot character NOT NULL,
198 PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd)
0009fa49 199);
200
ebf846e8 201CREATE 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);
084a2c0a 202
ebf846e8 203CREATE INDEX fourkeys_to_twokeys_idx_t_artist_t_cd_fourkeys_to ON fourkeys_to_twokeys (t_artist, t_cd);
204
887ce227 205--
ebf846e8 206-- Table: genre
887ce227 207--
ebf846e8 208CREATE TABLE genre (
87310237 209 genreid INTEGER PRIMARY KEY NOT NULL,
210 name varchar(100) NOT NULL
9c2c91ea 211);
212
87310237 213CREATE UNIQUE INDEX genre_name_genre ON genre (name);
ebf846e8 214
215--
4f6386b0 216-- Table: images
217--
218CREATE TABLE images (
219 id INTEGER PRIMARY KEY NOT NULL,
220 artwork_id integer NOT NULL,
221 name varchar(100) NOT NULL,
222 data blob
223);
224
225CREATE INDEX images_idx_artwork_id_images ON images (artwork_id);
226
227--
ebf846e8 228-- Table: liner_notes
229--
230CREATE TABLE liner_notes (
231 liner_id INTEGER PRIMARY KEY NOT NULL,
232 notes varchar(100) NOT NULL
233);
234
6bf6ba2f 235CREATE INDEX liner_notes_idx_liner_id_liner ON liner_notes (liner_id);
ebf846e8 236
237--
238-- Table: link
239--
240CREATE TABLE link (
241 id INTEGER PRIMARY KEY NOT NULL,
242 url varchar(100),
243 title varchar(100)
244);
245
9c2c91ea 246--
4f6386b0 247-- Table: lyric_versions
248--
249CREATE TABLE lyric_versions (
250 id INTEGER PRIMARY KEY NOT NULL,
251 lyric_id integer NOT NULL,
252 text varchar(100) NOT NULL
253);
254
255CREATE INDEX lyric_versions_idx_lyric_id_ly ON lyric_versions (lyric_id);
256
257--
258-- Table: lyrics
259--
260CREATE TABLE lyrics (
261 lyric_id INTEGER PRIMARY KEY NOT NULL,
262 track_id integer NOT NULL
263);
264
265CREATE INDEX lyrics_idx_track_id_lyrics ON lyrics (track_id);
266
267--
89034887 268-- Table: noprimarykey
269--
270CREATE TABLE noprimarykey (
271 foo integer NOT NULL,
272 bar integer NOT NULL,
273 baz integer NOT NULL
274);
275
ebf846e8 276CREATE UNIQUE INDEX foo_bar_noprimarykey ON noprimarykey (foo, bar);
277
89034887 278--
ebf846e8 279-- Table: onekey
9c2c91ea 280--
ebf846e8 281CREATE TABLE onekey (
282 id INTEGER PRIMARY KEY NOT NULL,
283 artist integer NOT NULL,
284 cd integer NOT NULL
9c2c91ea 285);
286
287--
ebf846e8 288-- Table: owners
9c2c91ea 289--
ebf846e8 290CREATE TABLE owners (
291 ownerid INTEGER PRIMARY KEY NOT NULL,
292 name varchar(100) NOT NULL
9c2c91ea 293);
294
295--
296-- Table: producer
297--
298CREATE TABLE producer (
299 producerid INTEGER PRIMARY KEY NOT NULL,
8fcf21b3 300 name varchar(100) NOT NULL
887ce227 301);
302
ebf846e8 303CREATE UNIQUE INDEX prod_name_producer ON producer (name);
304
9fcda149 305--
ebf846e8 306-- Table: self_ref
9fcda149 307--
ebf846e8 308CREATE TABLE self_ref (
8fcf21b3 309 id INTEGER PRIMARY KEY NOT NULL,
ebf846e8 310 name varchar(100) NOT NULL
9fcda149 311);
312
78060df8 313--
ebf846e8 314-- Table: self_ref_alias
78060df8 315--
ebf846e8 316CREATE TABLE self_ref_alias (
317 self_ref integer NOT NULL,
318 alias integer NOT NULL,
319 PRIMARY KEY (self_ref, alias)
78060df8 320);
321
ebf846e8 322CREATE INDEX self_ref_alias_idx_alias_self_ ON self_ref_alias (alias);
084a2c0a 323
ebf846e8 324CREATE INDEX self_ref_alias_idx_self_ref_se ON self_ref_alias (self_ref);
325
78060df8 326--
ebf846e8 327-- Table: sequence_test
78060df8 328--
ebf846e8 329CREATE TABLE sequence_test (
330 pkid1 integer NOT NULL,
331 pkid2 integer NOT NULL,
332 nonpkid integer NOT NULL,
333 name varchar(100),
334 PRIMARY KEY (pkid1, pkid2)
78060df8 335);
336
337--
ebf846e8 338-- Table: serialized
78060df8 339--
ebf846e8 340CREATE TABLE serialized (
341 id INTEGER PRIMARY KEY NOT NULL,
342 serialized text NOT NULL
78060df8 343);
344
345--
ebf846e8 346-- Table: tags
78060df8 347--
ebf846e8 348CREATE TABLE tags (
349 tagid INTEGER PRIMARY KEY NOT NULL,
350 cd integer NOT NULL,
351 tag varchar(100) NOT NULL
78060df8 352);
353
ebf846e8 354CREATE INDEX tags_idx_cd_tags ON tags (cd);
355
78060df8 356--
ebf846e8 357-- Table: track
78060df8 358--
ebf846e8 359CREATE TABLE track (
360 trackid INTEGER PRIMARY KEY NOT NULL,
361 cd integer NOT NULL,
362 position integer NOT NULL,
363 title varchar(100) NOT NULL,
364 last_updated_on datetime
365);
366
367CREATE INDEX track_idx_cd_track ON track (cd);
084a2c0a 368
ebf846e8 369CREATE UNIQUE INDEX track_cd_position_track ON track (cd, position);
084a2c0a 370
ebf846e8 371CREATE UNIQUE INDEX track_cd_title_track ON track (cd, title);
372
373--
374-- Table: treelike
375--
376CREATE TABLE treelike (
78060df8 377 id INTEGER PRIMARY KEY NOT NULL,
ebf846e8 378 parent integer,
379 name varchar(100) NOT NULL
380);
381
382CREATE INDEX treelike_idx_parent_treelike ON treelike (parent);
383
384--
385-- Table: twokeytreelike
386--
387CREATE TABLE twokeytreelike (
388 id1 integer NOT NULL,
389 id2 integer NOT NULL,
390 parent1 integer NOT NULL,
391 parent2 integer NOT NULL,
392 name varchar(100) NOT NULL,
393 PRIMARY KEY (id1, id2)
394);
395
396CREATE INDEX twokeytreelike_idx_parent1_parent2_twokeytre ON twokeytreelike (parent1, parent2);
084a2c0a 397
ebf846e8 398CREATE UNIQUE INDEX tktlnameunique_twokeytreelike ON twokeytreelike (name);
399
400--
401-- Table: twokeys
402--
403CREATE TABLE twokeys (
404 artist integer NOT NULL,
405 cd integer NOT NULL,
406 PRIMARY KEY (artist, cd)
407);
408
409CREATE INDEX twokeys_idx_artist_twokeys ON twokeys (artist);
410
411--
412-- Table: typed_object
413--
414CREATE TABLE typed_object (
415 objectid INTEGER PRIMARY KEY NOT NULL,
416 type varchar(100) NOT NULL,
417 value varchar(100) NOT NULL
78060df8 418);
419
0e80c4ca 420--
084a2c0a 421-- View: year2000cds
0e80c4ca 422--
084a2c0a 423CREATE VIEW year2000cds AS
424 SELECT cdid, artist, title FROM cd WHERE year ='2000';
78060df8 425
0009fa49 426COMMIT;