Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Issue setting Foreign key constraint
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01518536
Message ID:
01518951
Views:
37
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform