Say,
I have 3 tables.
User which contains basic info about the users.
SectionA which contains more info about the user.
SectionB which also contains more info about the user.
There can only be one SectionA and SectionB data for each user.
My idea was to create a table design like this:
id name section_a_id section_b_id
1 matt 1 1
Problem is, section_a_id and section_b_id cannot be auto incremented since they are not primary keys.
So I tried a different approach and decided that the id primary key in User should be a foreign key that refers to section_a_id and section_b_id`. But I'm unable to do so since mysql will only allow a reference to one table.
So how should I approach this situation?
If it's one to one relation, it will always be easier to combine the three tables into one big table, with nullable columns for Section tables.
Some positive points I can see for this approach:
It seems you have:
so the foreign keys have to be in SectionA and SectionB tables and they have to be the User table primary key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With