Reputation: 235
Can the primary key inbox_id in UserInbox be a foreign key for EmployerInformation and UserInformation?
Context:
Users and employers can send feedback to an administrator's inbox. This feedback will be stored in the table UserInbox. (image shown below)
Issue:
Both UserInformation and EmployerInformation have record_id as a unique identifier- I'm not sure if I can use the identifier (message_id) to connect UserInformation and EmployerInformation to UserInbox as it is hard to distinguish between the two record_ids.
Upvotes: 0
Views: 101
Reputation: 1251
It's not a good idea to make inbox_id
as foreign key in UserInfomation
and EmployerInformation
, because one user may have numbers of feedbacks, then user information will be duplicated many times.
One approach to this problem is using idea of inheritance, meaning that both UserInformation
and EmployerInformation
inherit from User
table, and User
table keeps common information of UserInformation
and EmployerInformation
like record_id
and img_id
. UserInbox
table will then keep record_id
as a foreign key.
UserInformation ------ User ----- EmployerInformation
|
UserInbox
Upvotes: 1