3i Infotech Papers: Sample Questions 176 - 176 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 176

» Database » MySQL

Essay Question▾

Describe in Detail

What is Relationship type?

Explanation

  • A Relationship Type defines a relationship set among entities of certain entity types.

  • There are three types of relationship types

    • One-to-one

    • One-to-many

    • Many-to-many

One-to-one

  • One-to-one relationships have 1 specified for both cardinalities, and do not seem to arise very often.

  • To illustrate a one-to-one, we require very specific business rules. Suppose we have People and Vehicles.

  • Assume that we are only concerned with the current driver of a vehicle, and that we are only concerned with the current vehicle that a driver is operating.

  • Then, we have a one-to-one relationship between Vehicle and Person (note the role shown for Person in this relationship):

Understanding of one-to-one relationship

Understanding of One-to-One Relationship

Understanding of one-to-one relationship

One-to-many

  • This type of relationship has 1 and n specified for cardinalities, and is very common in database designs.

  • Suppose we have customers and orders and the business rules:

    • An order is related to one customer, and

    • A customer can have any number (zero or more) of orders.

One-to-many relationship

One-to-Many Relationship

One-to-many relationship

Many-to-many

  • Many-to-many relationships have “many” specified for both cardinalities, and are also very common.

  • However, should you examine a data model in some business, there is a good chance you will not see any many-to-many relationships on the diagram.

  • In those cases, the data modeler has resolved the many-to-many relationships into two one-tomany relationships.

  • Suppose we are interested in courses and students and the fact that students register for courses: Any student may take several courses, A course may be taken by several students.

  • This situation is represented with a many-to-many relationship between Course and Student:

Many-to-many relationship

Many-to-Many Relationship

Many-to-many relationship