我们是否需要明确提及哪一列是外键列?

Do we need to explicitly mention which column is foreign key column?

当我们创建关系数据库table时,我们不得不使用外键列。很明显,否则我们无法创建关系。

不过我注意到有一个外键列就可以了,不用说tableA和tableB有外键关系

只要您会编写查询,就可以检索数据。

我们使用这个概念是为了让事情变得简单吗?我知道,当我查看已标记哪些列是外键列的数据库 table 模式时,很容易理解并开始使用它。

还有其他原因吗?

重点是Referential integrity。如果您不强制执行它,迟早会出现代码错误或其他意外,您的数据库将处于不一致状态。这些不一致问题之后很难或不可能修复。

When we create relational database tables, we have to use foreign key columns. It is obvious, otherwise we can not create relationships.

不正确。您 不需要 创建外键(尽管这是个好主意),而且它们不代表关系。他们加强关系的完整性。外键确保一列中的值存在于另一列中。

However, I noticed that it is enough to have a foreign key column, you do not need to say that there is a foreign key relationship in table A with table B. As long as you can write the queries you can retrieve the data.

是的,关系是基于数据本身,而不是通过包含外键。此外,外键不需要位于两个 table 之间,一个 table 可以有一个指向自身的外键。

Do we use this concept for make thing easy?

不,我们使用外键来保证完整性。它们恰好使 ERD 图更易于理解,这简直是一种奖励。