Created
April 13, 2017 20:09
-
-
Save jaredbeck/4aad0749164337b2e67eb10e81fb5ee3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table if exists d; | |
drop table if exists c; | |
drop table if exists b; | |
drop table if exists a; | |
create table a ( | |
id int not null auto_increment, | |
primary key (id) | |
); | |
create table b ( | |
id int not null auto_increment, | |
a_id int not null, | |
primary key (id), | |
foreign key (a_id) references a (id) on delete cascade | |
); | |
create table c ( | |
id int not null auto_increment, | |
a_id int not null, | |
primary key (id), | |
foreign key (a_id) references a (id) on delete cascade | |
); | |
create table d ( | |
id int not null auto_increment, | |
b_id int not null, | |
c_id int not null, | |
primary key (id), | |
foreign key (b_id) references b (id) on delete cascade, | |
foreign key (c_id) references c (id) on delete restrict | |
); | |
insert into a (id) values (1); | |
insert into b (id, a_id) values (1, 1); | |
insert into c (id, a_id) values (1, 1); | |
insert into d (id, b_id, c_id) values (1, 1, 1); | |
delete from a; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment