, , DML , .
:
create table parent
(
id integer not null primary key
);
create table child
(
id integer not null primary key,
parent_id integer not null references parent
);
create table grand_child
(
id integer not null primary key,
child_id integer not null references child
);
, ( ) ( ) , , , . , / , , .
, ( !) :
insert into grand_child values (1,1);
insert into child values (1,1);
insert into parent values (1);
commit;
, .
:
create table one
(
id integer not null primary key,
id_two integer not null
);
create table two
(
id integer not null primary key
id_one integer not null
);
alter table one add constraint fk_one_two (id_two) references two(id);
alter table two add constraint fk_two_one (id_one) references one(id);
.
, , , fk . :
(1, null);
(1, 1);
set id_two = 1
id = 1;
.
( , , !)
, , .
. , commit, . , , . insert ( delete update), , .