Search code examples
mysqlquery-optimization

Should I create 2 tables: first for usernames and passwords, and other for user information like dob, name, etc?


I'm really sorry if this is some kind of a bad question to ask, but I am really new to designing MySQL database for an online website(PHP + MySQL) of mine where user accounts need to be managed. In an old project, I had seen someone using 2 different tables: First for User account like username, user id, and passwords, and the other table for related data about the user like dob, name, etc.

I'm confused if this has any particular advantage in terms of optimization or helps in scaling the website. I preferred to use one table for both of these. Is that also advisable?


Solution

  • One table for username, password, email, date of birth, name, adress, etc. is totally correct.

    Though I agree with Capitain Skyhawh's logic to separate user_login/user_profile, I would personally put it in the same table since I find it a little useless to have a 1..1 relationship in the database.

    If profile was optionnal, I would definitely use 2 table.