# [EMAIL PROTECTED] / 2003-03-24 23:49:59 +0100:
> this is what Mysql Reference Manual tells me about creating foreign
> keys.
> I understood how to use them, except for the restrict here -------\
> |
> [CONSTRAINT symbol] FOREIGN KEY (index_col_name, ...) |
> REFERENCES table_name (index_col_name, ...) |
> [ON DELETE {CASCADE | SET NULL | NO ACTION |
> | RESTRICT}] <----------------------X
> [ON UPDATE {CASCADE | SET NULL | NO ACTION |
> | RESTRICT}] <----------------------/
>
> WHat are they?
> what's the use of them ?
They define "business rules", or, the properties of the foreign key:
* RESTRICT permits deletion of parent entity instance only when
there are no matching child entity instances.
* CASCADE always permits deletion of parent entity occurrence, and
deletes any matching child entity instances ("cascade" the
deletion to children).
* SET NULL: deletion of parent entity occurrence is always permitted,
and children (if any) have their foreign keys set to NULL.
* NO ACTION does what it says: it doesn't enforce any referential
integrity, parent may be deleted whether it has children or not,
and the deletion is not reflected in the children's foreign key
values.
The above is a reworded description taken from Handbook of
Relational Database Design (Addison Wesley), I hope I didn't break
any copyright. :)
--
begin 666 nonexistent.vbs
FreeBSD 4.8-RC
11:30AM up 1 day, 2:50, 10 users, load averages: 0.00, 0.01, 0.00
end
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]