Database design: 1 table or 2?

后端 未结 4 1660
我寻月下人不归
我寻月下人不归 2021-01-23 21:22

I have seen a few database designs where it has all user information in an account table, including password, email, DOB, First Name, Last Name etc.

I have seen some o

4条回答
  •  一整个雨季
    2021-01-23 21:50

    Well, the obvious main problem is that you have to deal with two tables if you want information from both. That's likely to complicate your queries a little and possibly reduce performance.

    Since all that information is dependent on a single key field (username most likely here), I tend to put it al in one table except in one very specific scenario: if, for example, you wanted to give someone access to the details in the first table but not the second, you could split it up for the purposes of security (opening up the first to everyone but restricting the second to only those who need the extra detail - but I'd probably move the password to the second table in that case).

    Other than that, I'd minimise the number of objects as long as it didn't get in the way of maintaining third normal form.

提交回复
热议问题