Entity Relationship Diagram in DBMS
Entity Relationship Diagram in DBMSOn this page, we will learn about what is Entity Relationship Diagram in DBMS, Units components of Entity Relationship Diagram ( Entity and its types, Attributes, Relationship, cardinality ).
What is Entity Relationship Diagram in DBMS?
To give a user view of how the data in a given database has a logical relationship amongst one another. With various units involved in the same like –
- Various Relationship
Unit components of Entity Relationship Diagram
Entity is a real object representation in an Entity Relationship diagram. For example if we want to create a database for a college in that case
students studying in the college will be considered as an
It can be anything like –
- Classrooms etc
The way of representing an entity is as follows –
Representation : A very simple
A set of all entities together is called an entity set.
Representation : A vertical Oval listing all entities.
Attributes are the properties of any given entity. For example for student entity the following will be the attributes –
- email ID
- Phone Number etc
Representation : A horizontal Oval.
There are the following types of attributes –
- Key attribute
- Composite attribute
- Multivalued attribute
- Derived attribute
A key attribute is the one which will uniquely identify and associate identity for an entity.
For example – For a student, his roll number or his studentID maybe its key attribute. For course offered by university, the course code like IT101 will be its key attribute.
Representation : It is same as Horizontal oval for an attribute. But, has an underline below the same.
As clear from its name a composite attribute composes of multiple units of attributes forming a larger one.
For example – Address may have following composite attributes –
- House Number
- Pin Code
Representation : Horizontal ovals mapped with further composite vertical ovals
A multivalued attribute is one, which may have more than one value for example. The phone number for student maybe multivalued as student may have one or more than 1 phone numbers.
Representation : Double Horizontal Oval
A derived attribute as the name suggests is the one that can be derived or calculated with the help of other attribute present itself.
For example – The age of the student can be calculated from date of birth present as an attribute.
Representation : Horizontal Dashed Oval.
The association between different entities that are existing in a database is depicted by relationship. For example in a university there may be thousands of students, which have enrolled in a few subjects each year.
So student entity is related to course entity by enrolment relationship.
Representation : Diamond box with entities connected to its edges as depicted in the image.
There are various types of relationships than can exist in a database which are –
Relationship set is mapping of different entity set to the others with the help of connected lines are depicted in the image.
Unary relationship is where there is only entity which is related to itself.
For example –
An entity person is related to itself, in relationship as married to.
Binary relationship is when there are 2 different entities associated with some relationship with one another.
For example –
Students enrolled in a course
n-ary relationship is when there is complex relationship amongst various entities. These are generally avoided by programmers to keep database architecture simple
For example –
Men eating animal, Animals eating animals, Men eating Plants, Animal eating plants etc etc. All of them are bound by eating relationship.
For a given entity sites, the number of entities that can participate in a relationship with another entity set is called cardinality.
One to One
When there is only one entity at a given instance participating in a relationship or association with only one different entity.
For example –
Man married woman.
At a given time only one man can marry one woman at a given time. So it is one to one relationship.
Another example would be earth revolves around the sun
Many to One
When there are multiple entities in a given entity set in relationship with only one entity of another or same entity set.
Assuming there is a rule that student can only enrol in 1 course this semester.
Students enrol in course.
There may be n number of students while the course offered is only 1.
Many to Many
Imagine there is no restriction in number of courses that can be enrolled in, then.
Many students can register in many different courses.
n students may register in m different courses.
All the entities in the entity set must participate in the relationship. For example the university forces, you to necessarily enrol in atleast 1 course, in that case it will be called total participation that student end.
It is represented by a double line joining entity and relationship.
It is when there maybe cases when some entities may and some entities may not participate in a relationship.
This is represented by single line joining entity and relationship.
Weak Entity and Weak Relationship
Weak entities are the one which may not have their own attributes and depend on other entity for their existence. For example the monthly instalment is dependent upon the loan entity and its attributes. The participation for weak entity type is always total.
This is represented by a double rectangle as represented in the image.
Weak relationship which is represented by double diamond connects relationship between a strong entity and a weak entity.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others