0% found this document useful (0 votes)
19 views

Introduction of ER Model

The ER model, or Entity-Relationship model, is a high-level data model used in database management systems to represent the logical view of data through E-R diagrams. It consists of entities, attributes, and relationships, with entities classified as strong or weak, and various types of attributes such as simple, composite, and derived. The model facilitates straightforward representation and communication of database structures, though it has limitations in expressing relationships between relationships.

Uploaded by

Pankaj Mahanta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Introduction of ER Model

The ER model, or Entity-Relationship model, is a high-level data model used in database management systems to represent the logical view of data through E-R diagrams. It consists of entities, attributes, and relationships, with entities classified as strong or weak, and various types of attributes such as simple, composite, and derived. The model facilitates straightforward representation and communication of database structures, though it has limitations in expressing relationships between relationships.

Uploaded by

Pankaj Mahanta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Introduction of ER Model

ER model in DBMS is the high-level data model. It stands for the Entity-relationship model
and is used to represent a logical view of the system from a data perspective. In simple words,
the entity relationship diagram is a blueprint that can used to create a database. E-R diagrams
are used to model real-world objects like a person, a car, a company and the relation between
these real-world objects.

Features of ER model

 E-R diagrams are used to represent E-R model in a database, which makes them easy
to be converted into relations (tables).

 E-R diagrams provide the purpose of real-world modeling of objects which makes them
intently useful.

 E-R diagrams require no technical knowledge and no hardware support.

 These diagrams are very easy to understand and easy to create even by a naive user.

 It gives a standard solution of visualizing the data logically.

ER diagram basically having three components:

Entity:

It is a real-world thing which can be a person, place, or even a concept. For Example:
Department, Admin, Courses, Teachers, Students, Building, etc are some of the entities of a
School Management System.

Entity type: The entity type is a collection of the entity having similar attributes.

Entity set: is a group of entities of similar kinds. It can contain entities with attributes that
share similar values. It's collectively a group of entities of a similar type. The entity set need
not be disjoint.

In summary, an Entity is an object of a Type Entity and the set of all entities is called an entity
set.

Entities are of two types:


Strong Entity – A strong entity is an entity type that has a key attribute. It doesn't depend on
other entities in the schema. A strong entity always has a primary key, and it is represented by
a single rectangle in the ER diagram.

Weak Entity – Weak entity type doesn’t have a key attribute and so we cannot uniquely
identify them by their attributes alone. Therefore, a foreign key must be used in combination
with its attributes to create a primary key. They are called Weak entity types because they can’t
be identified on their own. It relies on another powerful entity for its unique identity. A weak
entity is represented by a double-outlined rectangle in ER diagrams.

Strong Entity Weak Entity

Strong entity always has a primary key. While a weak entity has a partial
discriminator key.

Strong entity is not dependent on any Weak entity depends on strong entity.
other entity.

Strong entity is represented by a single Weak entity is represented by a double


rectangle. rectangle.

Two strong entity’s relationship is While the relation between one strong
represented by a single diamond. and one weak entity is represented by a
double diamond.

Strong entities have either total While weak entity always has total
participation or not. participation.
Attributes:
An entity which contains a real-world property called an attribute. For Example: The entity
employee has the property like employee id, salary, age, etc.
An entity is represented by a set of attributes. Attributes are descriptive properties possessed
by each member of an entity set.
Customer is an entity and its attributes are customerid, custmername, custaddress etc.
An attribute as used in the E-R model, can be characterized by the following attribute types.

a) Simple and Composite Attribute:


Simple attributes are the attributes which can’t be divided into sub parts.
Ex. Age of student

Composite Attributes are those which can be divided into subparts.


Ex. Name of a student can be divided into First Name, Middle Name, and Last Name.

b) Single-Valued and Multi-Valued Attribute:


Single Valued Attribute: An attribute having only single value for a particular entity is known
as single value attribute.
Ex. Age of student.
Multi-Valued Attributes: An attribute having more than one possible value for a particular
entity is known as multi-valued attribute.
Ex. Phone number of a student. A student may have more than one phone.

c) Derived Attribute:
Derived Attributes: An attribute that can be derived from other known attributes is known
as derived attribute.
Ex. Age of employees can be derived if you know date of birth and system date.
Age = System date – Date of birth
Stored Attributes: An attribute which cannot be derived by other known attributes is known
as stored attribute.
Ex. Date of birth of any employee.

d) NULL Valued Attribute:


Null stands for nothing. An attribute have a null value if either the value of that attribute is not
known or the value is not applicable.

Relationship & Relationship Sets

A relationship is defined as an association between several entities.

A set of relationships of similar type is called a relationship set. Like entities, a relationship too
can have attributes. These attributes are called descriptive attributes.

For example: Consider two Entity sets, Student and Course as shown in fig below. “Enrolled-
in” is a relationship set defined on the above 2 entity sets, which denotes the association
between Student and the Course in which enrolment is made. The association as shown below.

Mapping Cardinalities:
Mapping cardinalities or cardinality ratios, express the number of entities to which another
entity
can be associated via a relationship set. Mapping cardinalities are most useful in describing
binary
relationship sets, although they can contribute to the description of relationship sets that involve
more than two entity sets. For a binary relationship set R between entity sets A and B, the
mapping
customer borrow loan
cardinalities must be one of the following:
1. One to One:
An entity in A is associated with at most one entity in B, and an entity in B is associated with
at most one entity in A.
Example: A branch, say of a bank, has one head managing the branch.

2. One to Many:
An entity in A is associated with any number of entities in B. An entity in B is associated with
at the most one entity in A.
Example: Scientist can invent many inventions, but the invention is done by the only specific
scientist.

3. Many to One:
An entity in A is associated with at most one entity in B. An entity in B is associated with any
number in A.
Example: Student enrols for only one course, but a course can have many students.

4. Many to Many:
Entities in A and B are associated with any number of entities from each other.
Example: Employee can assign by many projects and project can have many employees.
Symbols Used in ER Model

ER Model is used to model the logical view of the system from a data perspective which
consists of these symbols:
Keys
Keys are used to specify the tuples distinctly in the given relation.
Various types of keys used in relational model are – Super key, Candidate Keys, primary keys,
foreign keys.
Let us discuss them with suitable example
1) Super Key(SK): It is a set of one or more attributes within a table that can uniquely identify
each record within a table. For example - Consider the Student table as follows-

The super key can be represented as follows-

Clearly using the (RegNo) and (RollNo, Phone, Name) we can identify the records uniquely
but (Name, Marks) of two students can be same, hence this combination not necessarily help
in identifying the record uniquely.
2) Candidate Key(CK): The candidate key is a subset of superset. In other words, candidate
key is a single attribute or least or minimal combination of attributes that uniquely identify
each record in the table. For example - in above given Student table, the candidate key is
RegNo, (RollNo,Phone). The candidate key can be
Thus every candidate key is a superkey but every superkey is not a candidate key.
3) Primary Key(PK): The primary key is a candidate key chosen by the database designer to
identify the tuple in the relation uniquely. For example - Consider the following representation
of primary key in the student table

Other than the above mentioned primary key, various possible primary keys can be (RollNo),
(RollNo, Name), (RollNo, Phone)
The relation among super key, candidate key and primary can be denoted by
Candidate Key= Super Key- Primary Key
Rules for Primary Key
(i) The primary key may have one or more attributes.
(ii) There is only one primary key in the relation.
(iii) The value of primary key attribute can not be NULL.
(iv) The value of primary key attributes does not be NULL.
4) Alternate Key:The alternate key is a candidate key which is not chosen by the database
designer to uniquely identify the tubles. For example-
5) Foreign key: Foreign key is a single attribute or collection of attributes in one table that
refers to the primary key of other table.
• Thus foreign keys refers to primary key.
• The table containing the primary key is called parent table and the table containing foreign
key is called child table.
• Example-

From above example, we can see that two tables are linked. For instance, we could easily find
out that the 'Student CCC has opted for ComputerSci course

Degree of a Relationship Set


The number of different entity sets participating in a relationship set is called the degree of a
relationship set.
1. Unary Relationship: When there is only ONE entity set participating in a relation, the
relationship is called a unary relationship. For example, one person is married to only one
person.
Unary Relationship
2. Binary Relationship: When there are TWO entities set participating in a relationship, the
relationship is called a binary relationship. For example, a Student is enrolled in a Course.

Binary Relationship
3. Ternary Relationship: When there are three entity sets participating in a relationship, the
relationship is called a ternary relationship.
4. N-ary Relationship: When there are n entities set participating in a relationship, the
relationship is called an n-ary relationship.

Advantages of E-R model


The major advantages of E-R model are as follows:
1. Straightforward relation representation: The relation representation of the database
model using E-R diagram are relatively more straightforward than other models.
2. Mapping with relational model: It can be easily mapped onto the relational model. The E-
R diagrams used in the E-R model can easily be transformed into relational tables. The
entities and attributes of E-R model can easily be transformed into relations (tables) and
columns (fields) in a relational model.
3. Communication tool: It is very simple and easy to understand with a minimum of training
efforts required. Therefore, the model can be used by the database designer to communicate
the design to the end user.
4. Design tool: E-R model can also be used as a design plan by the database developer to
implement a data model in specific database management software.
5. Easy conversion to other models: E-R diagrams can be easily converted to a network or
hierarchical data model.
6. Graphical representation: E-R model provides graphical and diagrammatical
representation of various entities, their attributes and relationships between entities.
7. Easy to modify: Modifications to E-R diagram at later stage is relatively easier than in other
models.

Limitation of E-R Model


E-R model cannot express relationships between relationships. In other words E-R model is
not capable to express relationship set between relationship sets.
This limitation can be overcome by using EER model.

Make an E-R diagram having two entity sets, Customer and Item. Cardinality
Ratio is many to many because a customer can buy any number of items and same
item can be purchased by more than one customer.

Make an E-R diagram with entities Customer, Loan and Payment

You might also like