Relationship
→ Relationship is an association among different related tables based on common field.
→ Records from multiple tables can be accessed or retrieved at a time, when relationship created.
→ To create relationship at least one table must have primary key.
Types of relationships
1. One to One Relationship
→ In one to one relationship, each record in the first table can have only one matching record in second table and vice versa.
→ Both table must have primary key to create one to one relationship.
→ Example: Counry:President, Country:Capital, Person:Passport
2. One to Many Relationship
→ In one to many relationship, each record in the first table can have more than one matching record in second table.
→ Only one table must have primary key to create one to many relationship.
→ Example: Office:Staff, Class:Student, Company:Staff, Country:Citizen
3. Many to Many Relationship
→ In many to many relationship, each record in the first table can have more than one matching record in second table and vice versa.
→ Required third table called "junction table" to create many to many relationship.
By defining the appropriate types of relationships—one-to-one, one-to-many, and many-to-many, ensure that data is organized, accessible, and maintains integrity. Properly implemented relationships not only enhance data retrieval but also support the overall functionality of database applications.
0 Comments