Relationship in Database
Relationship In Database: A relationship is an association between the instances of one or more entity types in the database which represents some information. For example, a student may be related to a class by being enrolled in that class in different universities, college and school. Another example is the link between mother and children. One mother may have many children, but each children has only one mother.
A relationship between entities is given a relevant name that represent some data in the data file. or example there is a relationship between Manager and Department in the same organization or institute. A manager manages the department with in the specific organization or institute.
Types of Relationship
The most common relationship in E-R Models are as follows
- Binary Relationship
- Unary Relationship
- Ternary Relationship
Binary Relationship
A relationship type of degree two is called binary relationship in the E-R Model of the relationship in the database. A binary relationship is the relationship between the instances of two entity types of the same data file of the same organization. It is the most common type of relationship countered in E-R data modeling of the database in the same organization. It is one of the famous relationship in database
A binary relationship is further divided into
- One-to-one Relationship
- One-to-many Relationship
- Many-to-many Relationship
One-to-one Relationship
In one-to-one relationship, two entity types are associated in such a way that for each instance in first entity type, there is only one matching instance in second entity type.
For example the relationship between COUNTRY and CAPITAL and PRINCIPAL and COLLEGE can be shown as
Example 2
One-to-many Relationship
In one-to-many relationship two entities are associated in such a way that for each instance in first entity type, there can be many matching instances in Second entity type. On the other hand, for each instance in second entity type, there is only one matching instance in first entity type in the same data file of same organization or institute.
Example
Example 2
Many-to-many Relationship
In many-to-many two entities are associated in such a way that for each instance in first entity type, there can be many matching instance in second entity type.
Example
Example 2