As we described in the tutorial Database models, Entity-relationship model is a model used for design and representation of relationships between data.
The main data objects are termed as Entities, with their details defined as attributes, some of these attributes are important and are used to identity the entity, and different entities are related using relationships.
In short, to understand about the ER Model, we must understand about:
Let's take an example to explain everything. For a School Management Software, we will have to store Student information, Teacher information, Classes, Subjects taught in each class etc.
Considering the above example, Student is an entity, Teacher is an entity, similarly, Class, Subject etc are also entities.
An Entity is generally a real-world object which has characteristics and holds relationships in a DBMS.
If a Student is an Entity, then the complete dataset of all the students will be the Entity Set
If a Student is an Entity, then student's roll no., student's name, student's age, student's gender etc will be its attributes.
An attribute can be of many types, here are different types of attributes defined in ER database model:
If the attribute roll no. can uniquely identify a student entity, amongst all the students, then the attribute roll no. will be said to be a key.
Following are the types of Keys:
We have covered Keys in details here in Database Keys tutorial.
When an Entity is related to another Entity, they are said to have a relationship. For example, A Class Entity is related to Student entity, becasue students study in classes, hence this is a relationship.
Depending upon the number of entities involved, a degree is assigned to relationships.
For example, if 2 entities are involved, it is said to be Binary relationship, if 3 entities are involved, it is said to be Ternary relationship, and so on.
In the next tutorial, we will learn how to create ER diagrams and design databases using ER diagrams.