-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Labels
bugSomething isn't workingSomething isn't working
Description
There is a Misconception in relationships.
It is correct that the cardinality of the strong table will always be 1, and therefore, there will only be "1 to 1" or "1 to n" relationships.
The conceptual problem lies in the ordinality (the minimum of the relationship):
- Physically, the weak table will always be 0, because when I insert a record into the strong table, the record never exists in the weak table, so it always starts at 0. Now conceptually, we can define that a book does not exist without pages, or that an invoice does not exist without lines, but the reality is that when we insert an invoice, we first insert the header, and at that moment there are no lines, and the database is not able to verify that at least one line must be included in the invoice; this must be verified in the program.
Whether to allow "One Only" or "One N" relationships to be defined in the weak table is, I would say, at the author's discretion. Personally, I wouldn't allow it, because it's not the database's responsibility. - Now, the conceptual error. Indeed, the strong table will never have a cardinality of many (N), only 1, but it must necessarily have an ordinality of zero or one. This is what defines whether the relationship is mandatory or optional. And the ERD Editor doesn't allow you to define the cardinality/ordinality "Zero One" in the strong table.
It is ironic that the ordinality (the extra 1 or 0) in the strong table, translates into a physical change in the weak table.
2.1) If the ordinality of the strong table is 1, it means the relationship is mandatory, and the foreign key in the weak table is defined as NOT NULL (it must always have a value and therefore there will always be a relationship.
2.2) If the ordinality of the strong table is 0, it means the relationship is optional, and the foreign key in the weak table is defined as NULL (it could have no value and therefore there will be no relationship).
Regards
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working