Thursday, 2 March 2017

Explain one-to-one relationship with example

Explain one-to-one relationship with example, one-to-one relationship in ER diagram, Define one-to-one relationship





One-to-one relationship

If an entity [a record] of one entity set is associated with maximum of one entity of the other entity set, then the relationship type is said to be one-to-one.

When we would say the relationship is one-to-one?
Assume two entity sets A and B. The relationship between A and B is one-to-one if and only if “an entity in A is associated with only one entity (record) in B and an entity in B is associated with only one entity (record) in A”.
If we put in simpler terms, entity set B is the one side for A and entity set A is the one side for B.
Example:
Let us assume a database for Airline Reservation System. Further assume that there are two entity sets Passengers and Boarding_Pass to model the passenger details and the flight tickets details respectively. If it is decided to issue each passenger a boarding pass, then the relationship between the entity sets Passengers and Boarding_Pass will be One-to-one.
As shown in the figure below, each passenger is allotted only one seat. Each passenger entity is associated with exactly one boarding_pass entity.

Sample one-to-one relationships showing links between entities of two entity sets


Observe carefully from the above figure the following;

  • Each passenger is allotted with exactly one seat. [look from passenger to boarding_pass]

  • Also, each seat is allotted to exactly one passenger. [look from boarding_pass to passenger]

The ER diagram for this is as follows;

One-to-one relationship between two entity sets Passengers and Boarding_Pass

Look at the ERD carefully. Arrow head is used in either side of the relationship Given. It indicates, one passenger for one boarding_pass, also one boarding_pass for one passenger.

**************












No comments:

Post a Comment

SQL exercises for beginners one

SQL Exercises for Beginners / Simple SQL Exercises with Answers / Solved SQL exercises / SQL solved exercises with simple conditions / So...