0

一个朋友正在开发一个网站,并且必须使用SQL制作一个数据库。他问为什么需要“has-a”或“is-a”关系,因为您可以获取一个实体集的主键并将其放在另一个适当的实体集中(反之亦然)以查找关系。

我无法回答这个问题,因为我刚刚被告知关系集就是数据库的工作方式。

编辑:我不想进入规范化。他指出,信息在关系集中被复制。

4

1 回答 1

1

您的问题将两个不同的抽象级别混合在一起,即概念级别和逻辑级别。

在概念层面,人们对描述所提议数据库的信息需求感兴趣。在不将描述偏向一种或另一种解决方案的情况下,这样做很有用。对此有用的一个模型是实体关系 (ER) 模型。在此模型中,主题被分解为实体(主题)和这些实体之间的关系。所有数据都被视为描述实体之一或关系之一的某些方面。

“Is-a”和“has-a”关系在这个抽象层次上是相关的。在这个级别,关系被识别,但没有被实施。

After creating a conceptual model of the database, but before creating the database itself, it's useful to go through a logical design phase, resulting in a logical model of the database. If the database is to be relational, it's useful to make the logical model a relational one. The relational model is the next level of abstraction.

This is where primary keys and foreign keys come in. These keys implement the relationships that were identified at the conceptual stage. This is how the relational model implements relationships. At this stage, you get involved with design issues like junction tables, table composition, and normalization.

In addition to the conceptual level and the logical level, there are the physical level and the script level. But these are outside the scope of your question.

这两种关系是待解决问题的特征。对主键的外键引用是建议解决方案的特点。

于 2012-10-21T11:54:42.257 回答