Ok, let me give you some details:
There is one table I'll call REFERENCES.
It contains the following columns:
Code:
REFERENCE_PK: the primary key
A_FK: a foreign key
B_FK: a foreign key
C_FK: a foreign key
REF_CODE: a string value describing the kind of reference
REF_DATA: reference data
DATA_LONG: more detailed data
DESCRIPTION: a description of this reference
This table is used to attach data to objects in the table.
All "objects" in the database have an "SK." For example, there is a table I'll call ANIMALS, they have an "ANIMAL_ID" (the primary key) and a column "ANIMAL_SK" (the only exception is the REFERENCES table, where the PK is used). This value is serialised in another table called OBJECTS:
Code:
OBJECT_ID: the primary key
REFTABLE: the table this object belongs to
This is how it works:
At least one column of A_FK, B_FK or C_FK should contain a value.
Let's assume A_FK
This value is then looked up in the OBJECTS table. If REFTABLE is "ANIMALS", this would mean the referenced object is that in the ANIMALS table with ANIMAL_SK=A_FK.
The same works with B_FK and C_FK. This way objects can be connected to each other.
REF_CODE would contain a code for this kind of connection, like "Image" if an image is being referenced.
Of course simple things like an animal's owner etc. are included in the respective table (like an ANIMAL's OWNER_ID etc.).
The advantage with this approach is that all kinds of references can be established without having to change the data model.
Now we'd like to add a certain code to an animal as a kind of upgrade to the the original product. As an example, I'll take an URL to a webpage with further information on an ANIMAL.
In this case, we'd add a row to REFERENCES with a REFERENCE_PK, no FK's, a certain REF_CODE that starts with an underscore ('_'), marking it as an internal value, and optionally some REF_DATA, DATA_LONG and DESCRIPTION values.
Rows with a REF_CODE beginning with an underscore will not be shown in the GUI.
We would then add a row to the OBJECTS table containing the REFERENCE_PK in the OBJECT_ID field and REFERENCES in the REF_TABLE column.
Now we can add rows to the REFERENCES table with a REF_CODE like "Website", an A_FK equal to the REFERENCE_PK of the row we just created and a B_FK to an ANIMAL. REF_DATA includes the URL.
The additional row with the underscore is desired because the customer cannot change the FK values, this way we keep him from fiddling with out program logic by creating a row with a REF_CODE="Website".
So REF_CODE has to be "Website" and one of the FK's has to match a value in OBJECTS that would point back to the row in REFERENCES.
Since the user may have added many other REFERENCES before, that FK cannot be known in advance, but it will be constant all the time. This is why I'd like it to be loaded at application startup.
I find this system very complicated myself and I'm not 100% sure if I've understood everything correctly since my co-worker only gave me a short introduction.
If you have any questions, do ask. Thank you very much for your support. :)