将数据保存在关系数据模型中

Keep data in relational data model

在关系模型中,为什么我们不将所有数据保存在一个 table 中?为什么我们需要创建多个 tables ?

我不是专家,但我认为如果 table 中有大量数据,这会消耗很多时间和资源。如果我们将它们分开,我们可以使操作更容易

取自https://www.bbc.co.uk/bitesize/guides/zvq634j/revision/1

A single flat-file table is useful for recording a limited amount of data. But a large flat-file database can be inefficient as it takes up more space and memory than a relational database. It also requires new data to be added every time you enter a new record, whereas a relational database does not. Finally, data redundancy – where data is partially duplicated across records – can occur in flat-file tables, and can more easily be avoided in relational databases.

Therefore, if you have a large set of data about many different entities, it is more efficient to create separate tables and connect them with relationships.

这取决于你的目的是什么。对于许多分析目的,单个 table 是最简单的方法。

但是,关系数据库实际上是为保持数据完整性而设计的。数据完整性的一个方面是任何给定的数据项都只存储在一个地方。例如,客户名称存储在客户 table 上,因此不需要在订单上重复 table。

这确保客户姓名始终正确,因为它存储在一个地方。

此外,通过单个 table 重复数据通常需要复制数据——这会使 table 的方式比需要的更大,从而减慢一切。