add test data
[dbsrgits/SQL-Translator.git] / t / data / pgsql / turnkey.sql
CommitLineData
5c804b41 1-- standalone, data table
2create table b (
3 b_id serial not null,
4 primary key (b_id),
5 name text
6);
7
92c2965b 8-- 1 single FK import, data table
88f2d2fd 9create table a (
10 a_id serial not null,
11 primary key (a_id),
12 b_id int not null,
13 foreign key (b_id) references b (b_id),
14 name text
15);
16
5c804b41 17-- 2 single FK import, link table between 'a' and 'b'
18-- note that 'a' both imports a FK from 'b', as well as links to 'b' via 'a_b'
65157eda 19create table a_b (
20 a_b_id serial not null,
21 primary key (a_b_id),
22 a_id int not null,
23 foreign key (a_id) references a (a_id),
24 b_id int not null,
25 foreign key (b_id) references b (b_id)
26);
88f2d2fd 27
92c2965b 28-- 1 single FK import, data table
65157eda 29create table c (
30 c_id serial not null,
31 primary key (c_id),
32 b_id int not null,
33 foreign key (b_id) references b (b_id),
34 name text
35);
88f2d2fd 36
92c2965b 37-- 1 single FK import, data table
65157eda 38create table d (
39 d_id serial not null,
40 primary key (d_id),
41 c_id int not null,
42 foreign key (c_id) references c (c_id),
43 name text
44);
88f2d2fd 45
92c2965b 46-- standalone, data table
88f2d2fd 47create table e (
48 e_id serial not null,
49 primary key (e_id),
50 name text
51);
52
92c2965b 53-- 2 single FK import, link table between 'c' and 'e'
65157eda 54create table c_e (
55 c_e_id serial not null,
56 primary key (c_e_id),
57 c_id int not null,
58 foreign key (c_id) references c (c_id),
59 e_id int not null,
60 foreign key (e_id) references e (e_id)
61);
88f2d2fd 62
92c2965b 63-- 1 triple FK import, link table between 'e', 'e', and 'e'
65157eda 64create table f (
65 f_id serial not null,
66 primary key (f_id),
92c2965b 67 e1_id int not null,
68 foreign key (e1_id) references e (e_id),
69 e2_id int not null,
70 foreign key (e2_id) references e (e_id),
71 e3_id int not null,
72 foreign key (e3_id) references e (e_id)
65157eda 73);
88f2d2fd 74
92c2965b 75-- 1 single FK import, 1 double FK import, link table between 'a', 'e', and 'e'
88f2d2fd 76create table g (
77 g_id serial not null,
78 primary key (g_id),
79 a_id int not null,
80 foreign key (a_id) references a (a_id),
81 e1_id int not null,
82 foreign key (e1_id) references e (e_id),
83 e2_id int not null,
84 foreign key (e2_id) references e (e_id)
85);
86
5c804b41 87-- 1 double FK import, 1 triple FK import, link table between 'a', 'a', 'e', 'e', and 'e'
65157eda 88create table h (
89 h_id serial not null,
90 primary key (h_id),
91 a1_id int not null,
92 foreign key (a1_id) references a (a_id),
93 a2_id int not null,
94 foreign key (a2_id) references a (a_id),
5c804b41 95 e1_id int not null,
96 foreign key (e1_id) references e (e_id),
97 e2_id int not null,
98 foreign key (e2_id) references e (e_id),
99 e3_id int not null,
100 foreign key (e3_id) references e (e_id)
101);
102
103-- 3 single FK import, link table between 'b', 'c', and 'd'
104create table i (
105 i_id serial not null,
106 primary key (i_id),
107 b_id int not null,
108 foreign key (b_id) references b (b_id),
109 c_id int not null,
110 foreign key (c_id) references c (c_id),
111 d_id int not null,
112 foreign key (d_id) references d (d_id)
65157eda 113);
114
5c804b41 115insert into b (name) values ('balloon');
116insert into b (name) values ('bangup');
117insert into b (name) values ('beluga');
118insert into b (name) values ('blanch');
119insert into b (name) values ('botch');
120insert into b (name) values ('brooch');
121insert into b (name) values ('broccoli');
122insert into b (name) values ('blitz');
123insert into b (name) values ('blintz');
124insert into a (name,b_id) values ('alkane',1);
125insert into a (name,b_id) values ('alkyne',2);
126insert into a (name,b_id) values ('amygdala',3);
127insert into a (name,b_id) values ('aorta',4);
128insert into a_b (a_id,b_id) values (1,5);
129insert into c (name,b_id) values ('cairn',6);
130insert into c (name,b_id) values ('cootie',7);
131insert into c (name,b_id) values ('cochlea',8);
132insert into d (name,c_id) values ('drake',1);
133insert into e (name) values ('ear');
134insert into e (name) values ('element');
135insert into e (name) values ('embryo');
136insert into e (name) values ('encumber');
137insert into e (name) values ('enhance');
138insert into e (name) values ('ependyma');
139insert into e (name) values ('epididymis');
140insert into e (name) values ('ergot');
141insert into e (name) values ('esophagus');
142insert into c_e (c_id,e_id) values (2,1);
143insert into f (e1_id,e2_id,e3_id) values (2,3,4);
144insert into g (a_id,e1_id,e2_id) values (2,5,6);
145insert into h (a1_id,a2_id,e1_id,e2_id,e3_id) values (3,4,7,8,9);
146insert into i (b_id,c_id,d_id) values (9,3,1);