Domanda

If I have two entities and the relation between them is 1:1. Also the participation of each of them is total... What I should do in this case in order to represent the relationship between them in the relational schema?

È stato utile?

Soluzione

If the 1:1 relationship with total participation is the only relationship between the two entities, you just merge them into a single relation. The choice of the primary key will be arbitrary (pick one of the PK of the original entities, while the other PK will be an alternate key).

If instead there are additional relationships between the two entities, which prevent the merge into a single relation, you can treat the entities as in a parent-child relationship, and the choice of where to put the foreign key is arbitrary.

Altri suggerimenti

In the relational model that's called a join depencency and it can be simply expressed as a constraint between two relations such that P(A) = P(B), where P(A) and P(B) are projections on relations A and B. Although it's easy to support in relational terms, unfortunately SQL makes it difficult or impossible to enforce join dependencies between different tables because standard SQL doesn't support the ability to update more than one table simultaneously. To implement in SQL you have to either combine them into one table or temporarily disable the constraint while the tables are updated.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top