在 PostgreSQL 中添加额外的外键列以进行快速查找是一种好习惯吗?

问题描述 投票:0回答:0

当我在

MySQL Workbench
中制作 ER 图时,软件会自动制作多个外键列,而我本以为只有一个外键:

在图像中,您会看到以下具有多列的外键:

  • fk_city_state1
    在城市表中:state_state_id + state_country_country_id
  • fk_district_city1
    表区:city_city_id + city_state_id + city_state_country_id
  • fk_street_district1
    在表格街道中:district_district_id + district_city_city_id + district_city_state_id + district_city_state_country_country_id

这篇文章我了解到

Workbench
这样做是为了索引目的。

当我在

pgAdmin 4
中制作这样的 ER 图时,不会添加这些额外的外键列。这是关于
pgAdmin 4
工具有多先进,或者这不是
PostgreSQL
中的一个好习惯吗?换句话说:添加这些外键手册并在它们上面放一个 ```Auto FK Index'' 是个好主意吗?

database postgresql indexing foreign-keys erd
© www.soinside.com 2019 - 2024. All rights reserved.