***Welcome to ashrafedu.blogspot.com * * * This website is maintained by ASHRAF***

Posts

    Thursday 5 December 2019

    Types of Relationships- Cardinality

    Cardinality


    In terms of data models, cardinality refers to the relationship between two tables. 
    Relationship can be of four types 

    • One-to-One Relationships
    • One-to-Many Relationships
    • May to One Relationships
    • Many-to-Many Relationships

    1. One-to-one:

    One entity from entity set X can be associated with at most one entity of entity set Y and vice versa. A single row of first table associates with single row of second table. 
    For example, 


    Here,
    • One student can enroll in at most one course.
    • One course can be enrolled by at most one student.
    2. One-to-many:
    One entity from entity set X can be associated with multiple entities of entity set Y, but an entity from entity set Y can be associated with at least one entity. A single row of first table associates with more than one rows of second table. 
    For example,

    Here,
    • One student can enroll in any number (zero or more) of courses.
    • One course can be enrolled by at most one student.
    3. Many to One
    More than one entity from entity set X can be associated with at most one entity of entity set Y. However, an entity from entity set Y may or may not be associated with more than one entity from entity set X. Many rows of first table associate with a single row of second table. 
    For example,

    Here,
    • One student can enroll in at most one course.
    • One course can be enrolled by any number (zero or more) of students.

    4. Many to Many:
    One entity from X can be associated with more than one entity from Y and vice versa. Many rows of first table associate with many rows of second table. 

    For example,

    Here,
    • One student can enroll in any number (zero or more) of courses.
    • One course can be enrolled by any number (zero or more) of students.



    No comments:

    Post a Comment