Well, I have a cash flow table , this table can be related to a process, order, account receivable, payable ... among several other tables that relate to and which can result in a posting in the box, the problem is when creating the relationships in this table, I do not know if I create several foreign keys, one for each table (in cash flow), or a relationship table (HAS) that are the alternatives that I know, I believe that it would be a problem to maintain the bank one of these two, since in the system the modules are dynamic and at any moment there may be a new one, and that you need to throw in the cash flow and have this release tracked related).
My idea would be a single relationship table that would serve all relationships, and that would be linked to another that would indicate the relationship table, Ex:
Relationship table:
CREATE TABLE IF NOT EXISTS 'SIS_REL' (
'PK_rel' int(11) NOT NULL,
'FK_rel_parent' int(11) NOT NULL COMMENT 'a',
'FK_rel_child' int(11) NOT NULL COMMENT 'b',
'FK_table_parent' int(11) NOT NULL COMMENT 'c',
'FK_table_child' int(11) NOT NULL COMMENT 'd',
PRIMARY KEY ('PK_rel')
);
Table that defines what the relationship will be:
CREATE TABLE IF NOT EXISTS 'SIS_rel_group' (
'PK_rel_group' int(11) NOT NULL AUTO_INCREMENT,
'rel_table' varchar(30) NOT NULL,
PRIMARY KEY ('PK_rel_group')
);
But I do not know if it would work and if it would be viable to look at the data modeling and performance standards, I see that some systems like SAP all relate to everything (or almost), but I have no idea how they do it in the bank, but surely they must have found a good solution, thank you in advance.