A Case for Ignoring Normalized Data

You cannot enforce RI in the second version, at least not once you have actual data in the tables. That is the problem with it. The universal contacts must link to the customer profile not the intermediate tables.
 
Hi Pat
I tend to Enforce Referential Integrity and if there are no matching records it will give you the standard error message
and you can then do something about it.
 
I'm not suggesting that you should not enforce RI. I ALWAYS enforce RI. It's a no-brainer. I do not have the chutzpah to think that I can handle relationships better then the database engine. And I'm not talking about null FK's. FK's that are optional can be null. Relationships such as Employee to CompanyVehicle are optional because the CompanyVehicle might exist in the car pool without being assigned to any employee. But order details do not have a life of their own and therefore have required specified for their FK.

The problem with this design is that each of the four related tables has its own range of autonumbers. There is no way that the SINGLE FK in the child table can have a FK that is valid in all four parent tables once you get into actual data entry.

The design as presented is flawed because the relationships don't work. The contacts has to be a dependent of the companies. That makes it a sibling of two of the tables depicted as parents. You can join to the siblings on FK to FK but that isn't an enforceable relationship.
 
I would suggest that you Enforce Referential Integrity between tables.
Why?
These diagrams are in the backend and serve only to show the relationships between table. Plus, this is moving to an SQL server. My databases do not allow deletions, all inserts come from queries.
Millions of records later, no RI, no problems.
 
I'm not suggesting that you should not enforce RI. I ALWAYS enforce RI. It's a no-brainer. I do not have the chutzpah to think that I can handle relationships better then the database engine. And I'm not talking about null FK's. FK's that are optional can be null. Relationships such as Employee to CompanyVehicle are optional because the CompanyVehicle might exist in the car pool without being assigned to any employee. But order details do not have a life of their own and therefore have required specified for their FK.

The problem with this design is that each of the four related tables has its own range of autonumbers. There is no way that the SINGLE FK in the child table can have a FK that is valid in all four parent tables once you get into actual data entry.

The design as presented is flawed because the relationships don't work. The contacts has to be a dependent of the companies. That makes it a sibling of two of the tables depicted as parents. You can join to the siblings on FK to FK but that isn't an enforceable relationship.
What are you talking about. The relationship has dual keys
The main ID (auto-count) and the TableID has a number unique to that that table.
 
Well I have always been told by numerous experts that Referential integrity is essential.
If RI is not enforced then you are able to add Child records in a related table.

The link between tblContactProfile - PK -ctpContactID and tblLinkUniversalAddresses on luaLinkToAddressesID
is a good example.
 
In every tblUniversalLink a second foreign key designates the Parent Table. That link exist for everyone of those relationships. It allows an unlimited number of connections between tables. This arrangement creates many-many even between multiple tables.

It requires a union query to display all of the Parent Tables in the same record set.
1701114845164.png
 

Attachments

  • 1701114540168.png
    1701114540168.png
    160.8 KB · Views: 73
Well I have always been told by numerous experts that Referential integrity is essential.
If RI is not enforced then you are able to add Child records in a related table.

The link between tblContactProfile - PK -ctpContactID and tblLinkUniversalAddresses on luaLinkToAddressesID
is a good example.
Not if every Insert in the entire database has data integrity and is inserted using a query. No data in these diagrams is able to be deleted at all or inserted directly. Database should never contain deletions. They should archive data, and every change of status should have a history.
 
Not if every Insert in the entire database has data integrity and is inserted using a query. No data in these diagrams is able to be deleted at all or inserted directly. Database should never contain deletions. They should archive data, and every change of status should have a history.
Can you upload a copy of the database with no confidential data?
 
You cannot enforce RI in the second version, at least not once you have actual data in the tables. That is the problem with it. The universal contacts must link to the customer profile not the intermediate tables.
Not True, Well not necessary anyway. The queries handle the RI.
 
Last edited:
Can you upload a copy of the database with no confidential data?
I'll have to make a new one that is not part of the overall program. between the front end and back end it is a couple of hundred megabytes. When I migrate this to SQL I'm going to break it down into components. At that point you can have a look. I've spent a few years making all this work.
 
The queries handle the RI.
NO, they don't.
Millions of records later, no RI, no problems.
Have you actually looked?
I've spent a few years making all this work.
Not surprising when you won't use the tools provided by the database engine and are using a design that does not comply with standard design patterns.

1-m relationships between tables are referred to as parent-child because it is a concept we all understand. A parent may have many children but a child may have one and only one parent (in the concept of a 1-m relationship). You have a design where you are saying that one child record may have FIVE different parents. That is the problem. You needed to create the relationships between the entity (whatever that table name is) and the child records. All the tables that you think are parents, presumably have a 1-1 relationship with the actual parent which seems to be missing from your schema and that is probably why this design is so awkward to work with and requires union queries.
Not if every Insert in the entire database has data integrity and is inserted using a query. No data in these diagrams is able to be deleted at all or inserted directly. Database should never contain deletions. They should archive data, and every change of status should have a history.
I could delete data from the tables:(

You also have an unnecessary relationship which you have highlighted in yellow for some reason. Since you don't enforce RI, this could be completely invalid and you would never even know. There is almost certainly some bad data out there waiting to be found so you might want to revisit the "millions of records later" assertion.
I am just interested in how you have related tables
If you think I'm wrong and you can correctly enforce RI on this many-parents to one child, please take the time to build three tables. Two parents, one child. Put some data in the parents, make sure the set of PKs is not identical so put 3 records in one parent and 5 in the other. Then create the relationships. The schema seems to work until, you try to add a child record with a FK that does not exist in ALL parents. Since the 5 "parent" records hold completely different sets of data, the autonumbers will soon diverge and one table will contain IDs that don't exist in all the others.

This is why, when you create a schema like this, you create an Entity table which contains the type code plus ALL the common fields so you can reduce the times you have to include the 1-1 tables in the join. The 1-1 tables only contain the FK and the columns that are unique to that Entity type. Beyond that, ALL relationships go to the Entity table which serves as the parent. If you have related tables that belong to one and only one of the entity types, you could conceivably deviate and relate to a specific entity type table but I probably would not.
 
If you think I'm wrong and you can correctly enforce RI on this many-parents to one child, please take the time to build three tables. Two parents, one child. Put some data in the parents, make sure the set of PKs is not identical so put 3 records in one parent and 5 in the other. Then create the relationships. The schema seems to work until, you try to add a child record with a FK that does not exist in ALL parents. Since the 5 "parent" records hold completely different sets of data, the autonumbers will soon diverge and one table will contain IDs that don't exist in all the others.
You must have missed part of the previous conversations. Each Relationship has a dual key. With a dual key each record relationship is unique. I'm not the only developer to use a second key to define an area. One of the few though.
 
Hubris is really bad for data security. Personally, I prefer to use RI because RI works no matter who/what updates data.
 

Users who are viewing this thread

Back
Top Bottom