Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 DELETE for bi-directional FKey Constraints.

Author  Topic 

dbleyl
Starting Member

21 Posts

Posted - 2004-04-07 : 11:59:28
How do you delete rows in tables like these:

TABLE A (PKey a, FKey b)
TABLE B (PKey b, FKey a)

Deleting from either one generates a conflicted column reference constraint.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-07 : 12:14:46
You'll have to drop the costraints in order to do it. Could you show us some sample data as to why one would have such a design?

Tara
Go to Top of Page

dbleyl
Starting Member

21 Posts

Posted - 2004-04-07 : 12:37:15
The constraints where generated from a Object-Relational mapper.

The idea is that B must reference one and only one A, although
A may have one or no B (inwhich case A's b is NULL).

So B is really an extension of A, as special case, it is one-to-one/ one-to-none.

If enforcing a one-to-one relationship this way doesn't make sense from the sql side, then I'll revisit the mapping, and consider making it
a one-to-many.
Go to Top of Page
   

- Advertisement -