Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I avoid a relation loop in my database design?

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.

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.

database design

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

like image 662
Krzysztof Antoniak Avatar asked Sep 25 '22 19:09

Krzysztof Antoniak


1 Answers

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.

like image 77
nvogel Avatar answered Sep 29 '22 01:09

nvogel