SQL数据库设计中的关系循环

时间:2022-07-30 12:44:30

I am making real-estate database and it seems i am doing something wrong, because i have several loops on my design. is it OK or i need to redesign all DB schema?

我正在做房地产数据库,似乎我做错了什么,因为我的设计有几个循环。我需要重新设计所有的DB模式吗?

Here is my Current Schema:

以下是我目前的模式:

SQL数据库设计中的关系循环

4 个解决方案

#1


4  

There is nothing wrong with "loops" in a database design. Sometimes you do need to traverse data in multiple directions.

数据库设计中的“循环”没有任何问题。有时确实需要在多个方向上遍历数据。

Whether this is model right for your application and the application needs is a much more difficult question and one that can't be answered without full details of the application and its data needs.

这是否适用于您的应用程序和应用程序需求是一个更加困难的问题,而没有完整的应用程序细节和数据需求就无法回答这个问题。

#2


1  

Without going into your particular design, there is nothing inherently wrong with cyclical relationships in general. Modeling some situations actually requires them (e.g. a "true" 1-to-1 relationship).

如果不深入您的特定设计,一般来说,循环关系没有任何固有的错误。对某些情况建模实际上需要它们(例如,“真正的”1比1关系)。

#3


0  

This looks fine to me if your goal is a highly normalized database. I don't see anything wrong with this design.

如果您的目标是高度规范化的数据库,那么在我看来这很好。我看不出这个设计有什么问题。

#4


0  

You are linking the Transaction to different tables that link to an intermediary table that is also linked to the transaction. Sounds kind of redundant?

您将事务链接到链接到与该事务相关的中介表的不同表。听起来有点冗余?

However, this is what the model is saying. A transaction has a TownRegion, and within that TownRegion, there are Areas, Districts, Streets, and Subways that a transaction could have all, some, or none of (depending on the rules set).

然而,这就是模型的意思。一个交易有一个城市区域,在这个城市区域内,有一些区域、地区、街道和地铁,一个交易可以拥有全部、部分或全部(取决于规则集)。

If any of the tables linked to the transaction that could be in different TownRegion's, the database must be changed. And unfortunately, the schema can be difficult to work with with some technologies, but it is the situation that defines the data in any case.

如果任何与事务关联的表都可以位于不同的TownRegion,则必须修改数据库。不幸的是,使用某些技术可能很难使用模式,但在任何情况下,定义数据的都是这种情况。

This is a slightly older post here, but I figured I should mention this.

这是一个稍老的帖子,但我想我应该提一下。

#1


4  

There is nothing wrong with "loops" in a database design. Sometimes you do need to traverse data in multiple directions.

数据库设计中的“循环”没有任何问题。有时确实需要在多个方向上遍历数据。

Whether this is model right for your application and the application needs is a much more difficult question and one that can't be answered without full details of the application and its data needs.

这是否适用于您的应用程序和应用程序需求是一个更加困难的问题,而没有完整的应用程序细节和数据需求就无法回答这个问题。

#2


1  

Without going into your particular design, there is nothing inherently wrong with cyclical relationships in general. Modeling some situations actually requires them (e.g. a "true" 1-to-1 relationship).

如果不深入您的特定设计,一般来说,循环关系没有任何固有的错误。对某些情况建模实际上需要它们(例如,“真正的”1比1关系)。

#3


0  

This looks fine to me if your goal is a highly normalized database. I don't see anything wrong with this design.

如果您的目标是高度规范化的数据库,那么在我看来这很好。我看不出这个设计有什么问题。

#4


0  

You are linking the Transaction to different tables that link to an intermediary table that is also linked to the transaction. Sounds kind of redundant?

您将事务链接到链接到与该事务相关的中介表的不同表。听起来有点冗余?

However, this is what the model is saying. A transaction has a TownRegion, and within that TownRegion, there are Areas, Districts, Streets, and Subways that a transaction could have all, some, or none of (depending on the rules set).

然而,这就是模型的意思。一个交易有一个城市区域,在这个城市区域内,有一些区域、地区、街道和地铁,一个交易可以拥有全部、部分或全部(取决于规则集)。

If any of the tables linked to the transaction that could be in different TownRegion's, the database must be changed. And unfortunately, the schema can be difficult to work with with some technologies, but it is the situation that defines the data in any case.

如果任何与事务关联的表都可以位于不同的TownRegion,则必须修改数据库。不幸的是,使用某些技术可能很难使用模式,但在任何情况下,定义数据的都是这种情况。

This is a slightly older post here, but I figured I should mention this.

这是一个稍老的帖子,但我想我应该提一下。