Attached photo, is just an initial draft of how will database look like.
I'm facing a loop between relationships and I'm not able to figure out how to get rid of it.
I'm currently developing an accounting application for my company, and here is a brief of the business requirements:
- First we have the companies table which lists all companies that are owned by my company
- For every company we have different types of operations or accounts. So it is a one to many relationship between table companies and tables operation types and account types
- We have a table listing all accounting operations in all companies. Each operation has one type. Which makes it a one to many relationship between operation types and operations. If I want to know this operation belongs to which company, then I have to check the type of operation and then I can get the company.
- We have a table listing all accounts in all companies. Each account has one account type. Which makes it a one to many relationship between account types and accounts. If I want to know this account belongs to which company, then I have to check the type of account and then I can get the company.
- My problem lies in this point, we have a table listing all operation lines. Each line is linked to an operation and an account at the same time (Loop occurring here). A line represents a debit or credit to a certain amount of money. An operation can be a collection of both debit and credit lines at the same time. Moreover, each line must be associated to a certain account