Professional Documents
Culture Documents
On Delete Cascade
On Delete Cascade
1 Definitely if the relation has a foreign key I am going to use ON DELETE CASCADE clause in the
child table. It is more appropriate to use ON DELETE CASCADE clause because if we don’t want to
keep data in the parent table then there is no use of keeping the track of parent table user data in
the child table.
Deleting a client from CLIENT table also deletes all client Categorise belonging to that Client from the
CLIENTCATEGORY table.
...
(...
Deleting a client from CLIENT table also deletes all client suburb belonging to that Client from the
CLIENTSUBURB table.
...
(...
The suburb record in SUBURB table can only be deleted if there are no orders for that Suburb in
CLIENTSUBURB table.
...
(...
4. For the relation of the SUBURB table and CLIENTSUBURB table I am going to use ON DELETE
RESTRICT clause in the child table.
The category record in CATEGORY table can only be deleted if there are no orders for that category
in CLIENTCATAGORY table.
...
(...
The Property record in PORPERTY table can only be deleted if there are no Offers for that Property in
OFFER table.
...
(...
48 CLIENT 4 5 CLIENT
CATEGORY CLIENT
CATEGORY SUBURB
100 1200
4800 6000
75
OFFER SUBURB
2400 80
2
PRICE
RANGE
40
1
PROPERTY
1200