denormalization - Cyclic reference in a database table -
I am quite ashamed to ask this, but recently there is a situation where I have three different one another Explain to me the types of banking institutions related to
Imagine a bank table that contains details of a regulated bank or a regular bank, which operates rural branches or rural branches operated under the branches of this bank or retail bank which does not fall In this hierarchy but only with the rural branch.
Earlier, I decided to keep 4 separate tables for the barriers of the FK (i. One governing bank, In the operation of branches, rural branch and retail bank branch) one. But since I went to create a communication table, I was confused because there could be a transaction between any of these institutions (example: rural branch and retail branch, etc. among rural branches etc.) it meant that I Only record the "source"; The 'Destination' ID of the banking unit, but to keep some data, the application logic to determine which queries are included for the query. I thought it was bad.
In addition, a USER table and user can be of any of these institutions, here too 4 separate tables of banking institutions are problematic. How do I know if a user is a rural branch or retail branch or a governing bank?
Therefore, I have a single bank table (essentially because they are the same institutions, because they can work with each other). I added a parent column in the table which will be the ID of the parent organization (which I am otherwise using from FK), then in a rural branch, its original column will have an operating bank ID. Retail branches do not have a parent, so its value is taped and so on.
The problem is that now a PK / FK relationship in the bank table, a cyclical reference.
My question is: how bad is it? And can the cap be a way?
Being self-referencing relationship is not uncommon, a fall is that many RDBMSs provide you with cascading self- Do not allow deletion. Apart from this, there is no major loss in this type of hierarchical relationship. For the convenience of these types of relationships, many database solutions also support expanded functionality. See
- on completing hierarchical questions using
- See details of some of the queries used in context itself. Relationships In addition to this, I can suggest that you have this bank table, but keep the secondary tables for bank types as each bank will have a record in the bank table, and additional Bank type is a record in one of the other tables holding distinctive extended properties, in this way the relationships will still be centralized, users will still be able to use a single FK Can be linked to the table, but your bank table does not match the extended properties for all types of different types.
Comments
Post a Comment