我可以避免我的数据库设计中的关系循环吗? [英] Can I avoid a relation loop in my database design?

查看:90
本文介绍了我可以避免我的数据库设计中的关系循环吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试设计数据库表,如下所示。我也有一个定义的帐户,但对我的问题并不重要。

I try to design database tables for the case shown below. I also have an account defined, but it's not important regarding my problem.


有一个操作列表(费用)。每个操作都可以在指定的POI中进行,地点可以分组成链(可选)。每个操作都可以有收件人,特别是商店链。

There is a list of operations (expenses). Each operation can take place in specified POI, places can be grouped in chains (optional). Each operation can have a recipient, specifically a shop chain.

我目前的设计如下所示。我甚至可以删除链表,有利于直接引用收件人,但它仍然在表之间留下循环。实际上,单行可能包含对定义不同收件人的收款帐户的引用。

My current design looks like below. I could even remove chain table in favor of direct reference to recipient, but it still leaves a loop between tables. Effectively, single row could contain references to place and receiving account having different recipient defined.

我可以看到唯一的解决方案是排除描述的情况的表格检查,但我想知道:有没有更好的解决方案?

The only solution I can see is a table check to exclude described case, but I'm wondering: is there a better fix?

推荐答案

据我所知,您的设计根本没有任何错误。没有必要改变它,因为它包含一个循环。在这种情况下,循环甚至不是循环依赖。如果你相信你目前的设计准确地模拟了它的意图,那么我看到没有必要改变它。

As far as I can tell there isn't anything fundamentally wrong with your design. There's no need to change it just because it contains a loop. The loop in this case doesn't even appear to be a circular dependency. If you believe your current design accurately models what it is intended to then I see no need to change it.

这篇关于我可以避免我的数据库设计中的关系循环吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆