Reputation: 6755
I'm designing a database for a web survey application. I have been studying this solution but I want to add additional tables to store other set of choices of the respondents. In particular I have one table for cities and one for foreign countries. Yet I like the idea of storing the answer to any question in a single unique_option_id
column, which can unequivocally identify the choice of one the three option tables.
What I then need is some sort of table (which I call option
) to maintain a column unique_option_id
which is the PIK
of country, city or multiple choice. Yet a foreign key can't reference to multiple tables. So I am not sure how I should implement a solution.
Upvotes: 0
Views: 153
Reputation: 137
If I understand your question correctly I think what you are want is a "composite foreign key"
Basically your forigen key will be contained in one column however be made up of PKI1 + PKI2 + PKI3, from the 3 other tables, It will depend on the database as to how exactly this is supported.
Hope that will help point you in the right direction.
Upvotes: 0