Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Issue setting Foreign key constraint
Message
 
 
À
22/07/2011 15:47:13
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01518536
Message ID:
01518951
Vues:
38
>>When the record is deleted in the Parent table and you specified CASCADE delete, all related records in the child table are deleted. If you somehow have cyclic relations it makes the above impossible.
>
>My FK constraint specifies that the FK field in child records is set to NULL, not deleted.
>
>This is a sample of my FK constraint code:
>
>
>alter table [dbo].[eq_file] add constraint [FK_eq_file_cost_cent] 
>foreign key ([cost_cent])
>references [dbo].[deptfile] ([cost_cent])
>on delete set null
>on update cascade
>
>
>But what I probably don't understand is how one table is linked to the other in SQL server.

I see. The relation is pretty much the same as in VFP. One table has a primary key (one field or combinations of fields) and this field is referenced in many records (1:M) in the child table. You can not insert a record into the child without first creating a parent or delete a record in the parent without some action in the child to not create orphans.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform