Today's Reading "SQL anti-patterns", inspired by many.
But one of the foreign key constraint to say, there are a few
Express their views.
Foreign key constraints, mainly used in
1 Make sure the insertion consistency, when inserting a foreign key as the other tables in the table when the checks related to the primary key of the table value exists.
(2) ensure that the update consistency, when the primary key is modified, all foreign key is specified as Patron key table will be updated.
I have a lot of system design is to avoid deletion, update the primary key to avoid in order to avoid the above two problems.
In reality, a record to be deleted, will inevitably lead to operational detail data deleted, even when using a foreign key constraint can not be avoided,
Such as deleting a commodity information, then the corresponding data inside the documents will be cascading deletes (using foreign key associations)
Will result in loss of data. We take a look at why users want to delete a product information,
from :http://www.fpccn.com/thread-2938-1-1.html