What's better - many small tables or one big table?

前端 未结 9 1167
半阙折子戏
半阙折子戏 2020-12-12 19:29

I\'ve got a database which will store profiles about individuals. These individuals have about 50 possible fields.

Some are common things like, first name, last nam

相关标签:
9条回答
  • 2020-12-12 19:58

    There is not database organization that's 100% correct, there's only one that's good enough for your purposes. If you don't foresee surpassing the capabilities of a single good database server in the future, then normalize the data and use plenty of constraints such as foreign keys, cascading deletes and such as that will make your database a joy to work with. On the other hand if you look at the databases of a lot of applications that have billions of requests you'll find that they forgo a lot of these niceties in the name of performance and scalability.

    0 讨论(0)
  • 2020-12-12 20:01

    I would recommend few tables. Over normalization is difficult to manage and you would end up writing complex queries which ends up with slow performance.

    Normalize only when absolutely needed and think in logical terms. With the limited information you provided above, I would go for three tables:

    Table 1: PersonalDetails Table 2: Activities Table 3: Miscellaneous

    There are other techniques to speed up the performance like clustering etc., which you can use depending upon your need.

    0 讨论(0)
  • 2020-12-12 20:06

    IMO, it is more important to worry about the quality of data stored than the number of tables that you need.

    For example, do you need to track changes? If John was 5'2" in January 2007 and is 5'11" in Oct 2010, do you want to know? If so, you will need to separate out the person from the height into two tables.

    How about hobbies - are they allowed to only have 3 hobbies? Can they have more / less? Is this something you would want to query in the future? If so, you need a separate table.

    You should read up on database design and normalization (there are several excellent threads on this site itself).

    https://stackoverflow.com/questions/tagged/normalization

    0 讨论(0)
提交回复
热议问题