Commit | Line | Data |
5c804b41 |
1 | -- standalone, data table |
2 | create 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 |
9 | create 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 |
19 | create 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 |
29 | create 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 |
38 | create 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 |
47 | create 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 |
54 | create 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 |
64 | create 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 |
76 | create 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 |
88 | create 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' |
104 | create 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 |
115 | insert into b (name) values ('balloon'); |
116 | insert into b (name) values ('bangup'); |
117 | insert into b (name) values ('beluga'); |
118 | insert into b (name) values ('blanch'); |
119 | insert into b (name) values ('botch'); |
120 | insert into b (name) values ('brooch'); |
121 | insert into b (name) values ('broccoli'); |
122 | insert into b (name) values ('blitz'); |
123 | insert into b (name) values ('blintz'); |
124 | insert into a (name,b_id) values ('alkane',1); |
125 | insert into a (name,b_id) values ('alkyne',2); |
126 | insert into a (name,b_id) values ('amygdala',3); |
127 | insert into a (name,b_id) values ('aorta',4); |
128 | insert into a_b (a_id,b_id) values (1,5); |
129 | insert into c (name,b_id) values ('cairn',6); |
130 | insert into c (name,b_id) values ('cootie',7); |
131 | insert into c (name,b_id) values ('cochlea',8); |
132 | insert into d (name,c_id) values ('drake',1); |
133 | insert into e (name) values ('ear'); |
134 | insert into e (name) values ('element'); |
135 | insert into e (name) values ('embryo'); |
136 | insert into e (name) values ('encumber'); |
137 | insert into e (name) values ('enhance'); |
138 | insert into e (name) values ('ependyma'); |
139 | insert into e (name) values ('epididymis'); |
140 | insert into e (name) values ('ergot'); |
141 | insert into e (name) values ('esophagus'); |
142 | insert into c_e (c_id,e_id) values (2,1); |
143 | insert into f (e1_id,e2_id,e3_id) values (2,3,4); |
144 | insert into g (a_id,e1_id,e2_id) values (2,5,6); |
145 | insert into h (a1_id,a2_id,e1_id,e2_id,e3_id) values (3,4,7,8,9); |
146 | insert into i (b_id,c_id,d_id) values (9,3,1); |