If a DB is designed as:
Table A a (type x) a is (PK) Table B a (type x) a is (PK) Table C a (type x) a is (FK) references A(a) a is (FK) references B(a)
Is this correct design? If not, what’s the best design for this case?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I believe the situation you are referring to is where C could be a child of A or B.
for example
if A is pages
B is pictures
and C is comments
C could be a comment for a picture or a comment for a page.
in this case I would adjust C to be a dual key as follows
You’ll then have to impliment data integrity from the application side.
So it’s fuzzy design in terms of foreign key implementation and data integrity. The question is if the application functionality is worth the chaos and if it will be in a well managed environment.