one primary key column foreign key to 2 other table columns.How to resolve data entry issue.
Posted
by Rohit
on Stack Overflow
See other posts from Stack Overflow
or by Rohit
Published on 2009-08-07T07:27:07Z
Indexed on
2010/03/09
5:06 UTC
Read the original article
Hit count: 271
primary-key
|foreign-keys
I have a requirement according to which I have to create a central Login system.We have 2 things Corporate and Brand each represented by tables "Corporate" and "Brand".
When a corporate gets registered,corporateID is given,When a user under that corporate gets registered there is a table corporateuser in which corporateID is a foreign key and CorporateUserID is a primary key.Similarly in the case of a brand.
So we have CorporateUserId and BrandUserID.
Now i have a table called RegisteredUsers in which i want to have corporate as well as brand users.UserID is a primary key in this table which is a foreign key to both corporateuser as well as Branduser.
now when i enter a corporateuser,I do an entry to corporateuser as well as RegisteredUsers.When i enter CorporateUserID in userID for RegisteredUsers.It gives foreign key violation error.
I fully understand this error.How can i achieve this.This requirement is very rigid.Please tell a workaround
© Stack Overflow or respective owner