5 months ago

Extension of the user model (database design)

Posted 5 months ago by fub


I am trying to design a database with the following constrains:

  • A Company has many Contacts
  • A Contact has optional fields like email, telephone, ...

Now a contact of a company should be able to edit some basic company data. For this, I want to allow each contact (with an email address) to send a signed URL by email which allows him to login. Some contacts do not have an email address, which is fine (they wont be able to login).

My question is now how I should structure this. I have two ideas in my mind:

A) User model extension

Extend the User model with some basic data (telephone for example) and a foreign key to the company. Also the email field should be nullable. This model will then be my "Contact" table. I think this is the cleaner solution, but I am not sure if making the email field nullable will have any consequences later on.


B) Separate user model for login and contact model for contact data

Keep the User model and the Contact model separate. I know have to manage two tables with "user" data: One with the contact data and one which is reponsible for the login.


Any suggestions which is the simpler or more idiomatic approach here?

Thanks, robin

Please sign in or create an account to participate in this conversation.