There are three major relationship models:
=> One-to-one:
As the name suggests you have one record in one table and corresponding to that you have one record in other table. We will take the same sample ER diagram defined for asset management. In the below diagram "Assets" can only have one "Status" at moment of time (Outdated / Need Maintenance and New Asset). At any moment of time "Asset" can only have one status of the above, so there is one-to-one relationship between them.
One-to-One relationship ER diagram
=> One-to-many:
In this many records in one table corresponds to the one record in other table. Example: -Every one customer can have multiple sales. So there exist one-to-many relationships between customer and sales table.
One "Asset" can have multiple "Maintenance". So "Asset" entity has one-to-many relationship between them as the ER model shows below.
One-to-Many Relationship ER diagram
=> Many-to-Many:
In this one record in one table corresponds to many rows in other table and also vice-versa.
For instance :- In a company one employee can have many skills like Java , c# etc and also
one skill can belong to many employees.
Given below is a sample of many-to-many relationship. One employee can have knowledge of multiple "Technology". So in order to implement this we have one more table "EmployeeTechnology" which is linked to the primary key of "Employee" and "Technology" table.
Many-to-Many Relationship ER diagram (DB)
=> One-to-one:
As the name suggests you have one record in one table and corresponding to that you have one record in other table. We will take the same sample ER diagram defined for asset management. In the below diagram "Assets" can only have one "Status" at moment of time (Outdated / Need Maintenance and New Asset). At any moment of time "Asset" can only have one status of the above, so there is one-to-one relationship between them.
One-to-One relationship ER diagram
=> One-to-many:
In this many records in one table corresponds to the one record in other table. Example: -Every one customer can have multiple sales. So there exist one-to-many relationships between customer and sales table.
One "Asset" can have multiple "Maintenance". So "Asset" entity has one-to-many relationship between them as the ER model shows below.
One-to-Many Relationship ER diagram
=> Many-to-Many:
In this one record in one table corresponds to many rows in other table and also vice-versa.
For instance :- In a company one employee can have many skills like Java , c# etc and also
one skill can belong to many employees.
Given below is a sample of many-to-many relationship. One employee can have knowledge of multiple "Technology". So in order to implement this we have one more table "EmployeeTechnology" which is linked to the primary key of "Employee" and "Technology" table.
Many-to-Many Relationship ER diagram (DB)
0 comments:
Post a Comment