I'm pretty new to database design.

I have an user table, an user_profile table and an user_address table.

In terms of good pratices. What is the best approach?

Option 1

User has_one User_profile
User has_one User_address

User_profile belongs to User
User_address belongs to User

Option 2

User has_one User_profile
User_profile has_one User_address

User_profile belongs to User
User_address belongs to User_profile

My user table stores the data to authentication, the user_profile table the personal infos (first_name, last_name, birth_date, phone...).

I think this is a trivial question, but i'm in doubt what is the best approach.


i could tell depends of your business logic :) But i think Option 2 is the right way as you probably never use the Address object without the Profile one. And perhaps you could have a profile with more than 1 address. And if your business is to have only 1 address and this address is required, why not storing address in the profile Object, in json by example.

  • 2
    This is a database, there are tables in there, not objects. Furthermore, why would you store data with predictable structure in a JSON? – dezso Nov 3 '16 at 15:18
  • i just usually represent tables as object, like in models. Never mind. And for JSON, i often have projects with non predictable structure for address, due to difference between countries ans postal rules (nb char, nb lines, zip, etc.) It was just a suggestion. But what about user1301037 question ? – Zoé R. Nov 3 '16 at 16:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.