tru
tru

Reputation: 143

Can an Identifying relationship be one-to-one?

Let's take an employee entity set. Employees purchase insurances to cover one dependent. We wish to store Name and Age of the dependents. If the employee can one name only one dependent, the relationship between them would be one-to-one in our database. Dependents do not have a key. I am confused if dependents can be modeled as a Weak Entity set, whose corresponding Owner Entity Set being Employees, because I read that Identifying relationships should be one-to-one from the owner entity set to weak entity set.

Upvotes: 0

Views: 269

Answers (1)

Christophe
Christophe

Reputation: 73510

Yes, an identifying relationship can be one-to-one:

A weak entity is an entity that cannot be uniquely identified by its attributes alone. It is dependent on an owner, and it can only be uniquely identified with the identifying relationship to its owner.

However, this does not mean that the weak entity does not have a primary key. All entities have an identity and hence a primary key. For the weak entities it just means that the primary key is more than you would expect.

In practice, the primary key of the owning entity must be included in the primary key of the weak entity. Two cases can be considered:

  • The owning entity has a one-to-many relationship with the weak entity. In this case, the primary key of the weak entity is a composite primary key made of the primary key of the owning entity, and one or several attributes of the weak entity that allow to uniquely distinguish several weak entities related to the same owner. Example:

                     1     N
    Purchase order ----<>---- Purchase order line 
    

    Here the purchase order would have a primary key id and the purchase order may have an attribute line_number that uniquely identify the lines belonging to the same purchase order. The primary key of that table would then be made of id and line_number together.

  • The owning entity has a one-to-one relationship with the weak entity. This is your example. As a consequence, there is only one weak entity for any owning entity and hence no need to have an attribute to distinguish them: the weak entity would be uniquely identified by the primary key of the owner.

Upvotes: 0

Related Questions