-
Notifications
You must be signed in to change notification settings - Fork 553
/
Copy pathmysql_test_schema.sql
360 lines (317 loc) · 9.13 KB
/
mysql_test_schema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
CREATE TABLE event_one (
id serial PRIMARY KEY NOT NULL,
name VARCHAR(255),
face enum('happy','sad','bitter'),
mood enum('happy','sad','bitter'),
day enum('monday','tuesday','wednesday')
);
CREATE TABLE magic (
id int PRIMARY KEY NOT NULL AUTO_INCREMENT,
id_two int NOT NULL,
id_three int,
bool_zero bool,
bool_one bool NULL,
bool_two bool NOT NULL,
bool_three bool NULL DEFAULT FALSE,
bool_four bool NULL DEFAULT TRUE,
bool_five bool NOT NULL DEFAULT FALSE,
bool_six bool NOT NULL DEFAULT TRUE,
string_zero VARCHAR(1),
string_one VARCHAR(1) NULL,
string_two VARCHAR(1) NOT NULL,
string_three VARCHAR(1) NULL DEFAULT 'a',
string_four VARCHAR(1) NOT NULL DEFAULT 'b',
string_five VARCHAR(1000),
string_six VARCHAR(1000) NULL,
string_seven VARCHAR(1000) NOT NULL,
string_eight VARCHAR(1000) NULL DEFAULT 'abcdefgh',
string_nine VARCHAR(1000) NOT NULL DEFAULT 'abcdefgh',
string_ten VARCHAR(1000) NULL DEFAULT '',
string_eleven VARCHAR(1000) NOT NULL DEFAULT '',
big_int_zero bigint,
big_int_one bigint NULL,
big_int_two bigint NOT NULL,
big_int_three bigint NULL DEFAULT 111111,
big_int_four bigint NOT NULL DEFAULT 222222,
big_int_five bigint NULL DEFAULT 0,
big_int_six bigint NOT NULL DEFAULT 0,
int_zero int,
int_one int NULL,
int_two int NOT NULL,
int_three int NULL DEFAULT 333333,
int_four int NOT NULL DEFAULT 444444,
int_five int NULL DEFAULT 0,
int_six int NOT NULL DEFAULT 0,
float_zero float,
float_one float,
float_two float(2,1),
float_three float(2,1),
float_four float(2,1) NULL,
float_five float(2,1) NOT NULL,
float_six float(2,1) NULL DEFAULT 1.1,
float_seven float(2,1) NOT NULL DEFAULT 1.1,
float_eight float(2,1) NULL DEFAULT 0.0,
float_nine float(2,1) NULL DEFAULT 0.0,
bytea_zero binary,
bytea_one binary NULL,
bytea_two binary NOT NULL,
bytea_three binary NOT NULL DEFAULT 'a',
bytea_four binary NULL DEFAULT 'b',
bytea_five binary(100) NOT NULL DEFAULT 'abcdefghabcdefghabcdefgh',
bytea_six binary(100) NULL DEFAULT 'hgfedcbahgfedcbahgfedcba',
bytea_seven binary NOT NULL DEFAULT '',
bytea_eight binary NOT NULL DEFAULT '',
time_zero timestamp,
time_one date,
time_two timestamp NULL DEFAULT NULL,
time_three timestamp NULL,
time_five timestamp NULL DEFAULT CURRENT_TIMESTAMP,
time_nine timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
time_eleven date NULL,
time_twelve date NOT NULL,
time_fifteen date NULL DEFAULT '19990108',
time_sixteen date NOT NULL DEFAULT '1999-01-08'
);
CREATE TABLE magicest (
id int primary key not null auto_increment,
aa json NULL,
bb json NOT NULL,
kk double precision NULL,
ll double precision NOT NULL,
mm tinyint NULL,
nn tinyint NOT NULL,
oo tinyint(1) NULL,
pp tinyint(1) NOT NULL,
qq smallint NULL,
rr smallint NOT NULL,
ss mediumint NULL,
tt mediumint NOT NULL,
uu bigint NULL,
vv bigint NOT NULL,
ww float NULL,
xx float NOT NULL,
yy double NULL,
zz double NOT NULL,
aaa double precision NULL,
bbb double precision NOT NULL,
ccc real NULL,
ddd real NOT NULL,
eee boolean NULL,
fff boolean NOT NULL,
ggg date NULL,
hhh date NOT NULL,
iii datetime NULL,
jjj datetime NOT NULL,
kkk timestamp NULL,
lll timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
mmm binary NULL,
nnn binary NOT NULL,
ooo varbinary(100) NULL,
ppp varbinary(100) NOT NULL,
qqq tinyblob NULL,
rrr tinyblob NOT NULL,
sss blob NULL,
ttt blob NOT NULL,
uuu mediumblob NULL,
vvv mediumblob NOT NULL,
www longblob NULL,
xxx longblob NOT NULL,
yyy varchar(100) NULL,
zzz varchar(100) NOT NULL,
aaaa char NULL,
bbbb char NOT NULL,
cccc text NULL,
dddd text NOT NULL,
eeee tinyint(2) NULL,
ffff tinyint(2) NOT NULL
);
create table owner (
id int primary key not null auto_increment,
name varchar(255) not null
);
create table cats (
id int primary key not null auto_increment,
name varchar(255) not null,
owner_id int references owner (id)
);
create table toys (
id int primary key not null auto_increment,
name varchar(255) not null
);
create table cat_toys (
cat_id int not null references cats (id),
toy_id int not null references toys (id),
primary key (cat_id, toy_id)
);
create table dog_toys (
dog_id int not null,
toy_id int not null,
primary key (dog_id, toy_id)
);
create table dragon_toys (
dragon_id varchar(100),
toy_id varchar(100),
primary key (dragon_id, toy_id)
);
create table spider_toys (
spider_id varchar(100) primary key,
name varchar(100)
);
create table pals (
pal varchar(100) primary key,
name varchar(100)
);
create table friend (
friend varchar(100) primary key,
name varchar(100)
);
create table bro (
bros varchar(100) primary key,
name varchar(100)
);
create table enemies (
enemies varchar(100) primary key,
name varchar(100)
);
create table chocolate (
dog varchar(100) primary key
);
create table waffles (
cat varchar(100) primary key
);
create table tigers (
id binary primary key,
name binary null
);
create table elephants (
id binary primary key,
name binary not null,
tiger_id binary null unique,
foreign key (tiger_id) references tigers (id)
);
create table wolves (
id binary primary key,
name binary not null,
tiger_id binary not null unique,
foreign key (tiger_id) references tigers (id)
);
create table ants (
id binary primary key,
name binary not null,
tiger_id binary not null,
foreign key (tiger_id) references tigers (id)
);
create table worms (
id binary primary key,
name binary not null,
tiger_id binary null,
foreign key (tiger_id) references tigers (id)
);
create table byte_pilots (
id binary primary key not null,
name varchar(255)
);
create table byte_airports (
id binary primary key not null,
name varchar(255)
);
create table byte_languages (
id binary primary key not null,
name varchar(255)
);
create table byte_jets (
id binary primary key not null,
name varchar(255),
byte_pilot_id binary unique,
byte_airport_id binary,
foreign key (byte_pilot_id) references byte_pilots (id),
foreign key (byte_airport_id) references byte_airports (id)
);
create table byte_pilot_languages (
byte_pilot_id binary not null,
byte_language_id binary not null,
primary key (byte_pilot_id, byte_language_id),
foreign key (byte_pilot_id) references byte_pilots (id),
foreign key (byte_language_id) references byte_languages (id)
);
create table cars (
id integer not null,
name text,
primary key (id)
);
create table car_cars (
car_id integer not null,
awesome_car_id integer not null,
relation text not null,
primary key (car_id, awesome_car_id),
foreign key (car_id) references cars(id),
foreign key (awesome_car_id) references cars(id)
);
create table trucks (
id integer not null,
parent_id integer,
name text,
primary key (id),
foreign key (parent_id) references trucks(id)
);
CREATE TABLE race (
id integer PRIMARY KEY NOT NULL,
race_date timestamp,
track text
);
CREATE TABLE race_results (
id integer PRIMARY KEY NOT NULL,
race_id integer,
name text,
foreign key (race_id) references race(id)
);
CREATE TABLE race_result_scratchings (
id integer PRIMARY KEY NOT NULL,
results_id integer NOT NULL,
name text NOT NULL,
foreign key (results_id) references race_results(id)
);
CREATE TABLE pilots (
id integer NOT NULL,
name text NOT NULL
);
ALTER TABLE pilots ADD CONSTRAINT pilot_pkey PRIMARY KEY (id);
CREATE TABLE jets (
id integer NOT NULL,
pilot_id integer NOT NULL,
age integer NOT NULL,
name text NOT NULL,
color text NOT NULL
);
ALTER TABLE jets ADD CONSTRAINT jet_pkey PRIMARY KEY (id);
ALTER TABLE jets ADD CONSTRAINT pilots_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
CREATE TABLE languages (
id integer NOT NULL,
language text NOT NULL
);
ALTER TABLE languages ADD CONSTRAINT language_pkey PRIMARY KEY (id);
-- Join table
CREATE TABLE pilot_languages (
pilot_id integer NOT NULL,
language_id integer NOT NULL
);
-- Composite primary key
ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_pkey PRIMARY KEY (pilot_id, language_id);
ALTER TABLE pilot_languages ADD CONSTRAINT pilot_language_fkey FOREIGN KEY (pilot_id) REFERENCES pilots(id);
ALTER TABLE pilot_languages ADD CONSTRAINT languages_fkey FOREIGN KEY (language_id) REFERENCES languages(id);
CREATE TABLE powers_of_two (
vid int(10) unsigned NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL DEFAULT '',
machine_name varchar(255) NOT NULL DEFAULT '',
description longtext,
hierarchy tinyint(3) unsigned NOT NULL DEFAULT '0',
module varchar(255) NOT NULL DEFAULT '',
weight int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (vid),
UNIQUE KEY machine_name (machine_name),
KEY list (weight,name)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- Previously the generated code had a naming clash when a table was called 'updates'
CREATE TABLE updates (
id integer PRIMARY KEY NOT NULL
);