Say I have a MySql database for tracking people. There is a parent table for records of each parent and a child table for records for each child.

I could have a total_children field in the parent table, but then again to get that answer I could simply count how many children records have parent_id of the parent I'm looking for. I hate keeping redundant data, but for certain things having this logged twice may be a performance benefit during certain operations (not having to access the child table every time).

This is a very simple example, but I'm asking this as a bigger picture. I have a good size database (25+ tables with 10,000+ records in multiple tables). Is it standard practice to keep such records in other tables when you could get the same information by executing a more complex select statement?

有帮助吗?

解决方案

What you are asking about is called denormalization. Its basically process of systematically breaking the Normal Form Rules.

It is fine to do this when you understand the impacts, and it IS a common practice.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top