Creating Two Cascading Foreign Keys Against Same Target Table/Col

Posted by alram on Stack Overflow See other posts from Stack Overflow or by alram
Published on 2010-04-01T14:24:52Z Indexed on 2010/04/12 13:43 UTC
Read the original article Hit count: 273

I have the following tables:

 user (userid int [pk], name varchar(50))
 action (actionid int [pk], description nvarchar(50))

being referenced by another table that captures the relationship:

<user1> <action>'s <user2>.

I did this with the following table:

userAction (userActionId int [pk], actionid int [fk: action.actionid], **userId1 int [fk ref's user.userid; on del/update cascade],  userId2 int [fk ref's user.userid; on del/update cascade]**).

However, when I try to save the userAction table i get an error because I have two cascading fk's against user.userid.

Is there any way to remedy this or must I use a trigger?

© Stack Overflow or respective owner

Related posts about tsql

Related posts about database-design