iNeedHelp
iNeedHelp

Reputation: 235

How to distinguish between classes with the same unique identifier in a class diagram?

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) enter image description here

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

Answers (1)

tning
tning

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

Related Questions