0% found this document useful (0 votes)
33 views7 pages

studymaterialUnit2ERDiagram KschemeUpload

Uploaded by

vahaneaniket
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)
33 views7 pages

studymaterialUnit2ERDiagram KschemeUpload

Uploaded by

vahaneaniket
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/ 7

Entity-relationship model

The entity-relationship (E-R) data model is a high level data model consisting of entities and relationships among the entities present in
the database. ER model is a diagrammatic representation of logical structure of database
The E-R data model employs three basic notions: entity sets, relationship sets, and attributes.
for example Suppose we design a school database. In this database, the student will be an entity with attributes like rollno, name, age, etc.
The Course can be another entity with attributes like coursecode,cname etc and there will be a relationship between them.

Entity:

An Entity is generally a real-world object that is distinguishable from all other objects. It may be an object, person, place or event that
stores data in a database.example: Student is an entity, Teacher is an entity, similarly, Class, Subject are also entities.
An entity has a set of attributes, and the values for some set of attributes may uniquely identify an entity. For instance, a student has an
attribute Roll_No whose value uniquely identifies that student.

Strong Entity

A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not depend on other entities in the Schema. It has a primary
key that helps in identifying it uniquely, and it is represented by a rectangle.

Weak Entity

Weak entity is an entity that depends on another entity. Weak entity doesn't have any key attribute of its own. Double rectangle is used to
represent a weak entity.

Entity Set:

An entity set is a set of entities of the same type that share the same properties, or attributes.
If a Student is an Entity, then the complete dataset of all the students will be the Entity Set

Attributes:

Attributes are descriptive properties possessed by each member of an 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.
For each attribute, there is a set of permitted values, called the domain, or value set, of that attribute.

An attribute can be of many types, here are different types of attributes defined in ER database model:

Simple attribute: The attributes with values that are atomic and cannot be broken down further that is, they are not divided into subparts
are simple attributes. For example, student's EnrollNo.

Composite attribute: A composite attribute is made up of more than one simple attribute and can be divided into subparts. For example,
student's address will contain, house no., street name, pincode etc.

Derived attribute: The value for this type of attribute can be derived from the values of other related attributes or entities. For example,
age of students in a class. If the student entity set also has an attribute date-of-birth, we can calculate age from date-of-birth and the
current date. Thus, age is a derived attribute. In this case, date-of-birth may be referred to as a base attribute, or a stored attribute. The
value of a derived attribute is not stored, but is computed when required.

Single-valued attribute: As the name suggests, they have a single value. For example, students Roll No in student entity can have only one
value.

Multi-valued attribute: Attributes having set of values for a specific entity is a multivalued attribute. For example, phoneno attribute of a
student entity.

Descriptive attribute: The attribute which describes the other attributes are called as Descriptive attribute.

Null attribute: A NULL value is used when an entity does not have a value for an attribute.
Keys:

A key allows us to identify a set of attributes that suffice to distinguish entities from each other. Keys also help uniquely identify
relationships, and thus distinguish relationships from each other.
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:
1. Super Key
2. Candidate Key
3. Primary Key

Relationships:

A relationship is an association among several entities.


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,
because 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 three entities are involved, it is said to be Ternary relationship,
and so on.

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
For a binary relationship set R between entity sets A and B, the mapping cardinality must be one of the following:
• 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.

• One to many. An entity in A is associated with any number (zero or more) of entities in B. An entity in B, however, can be associated with
at most one entity in A.

• Many to one. An entity in A is associated with at most one entity in B. An entity in B, however, can be associated with any number (zero
or more) of entities in A.
• Many to many. An entity in A is associated with any number (zero or more) of entities in B, and an entity in B is associated with any
number (zero or more) of entities in A.

Components of ER Diagram

An E-R diagram can express the overall logical structure of a database graphically. E-R diagram consists of the following major components
and there are defined symbols and shapes to represent each one of these components.

Entity

Simple rectangular box represents an Entity.

Attributes

Ellipse is used to represent attributes of any entity.

Lines, which link attributes to entity sets and entity sets to relationship sets
Double lines, which indicate total participation of an entity in a relationship set

Key Attribute

Key attribute represents the main characteristic of an Entity. It is used to represent a Primary key. Ellipse with the text underlined,
represents Key Attribute.
Derived Attribute

Derived attributes are those which are derived based on other attributes, for example, age can be derived from date of birth.
Dashed ellipses, which denote derived attributes
To represent a derived attribute, another dotted ellipse is created inside the main ellipse.

Multivalued Attribute

Double Ellipse, one inside another, represents the multivalued attributes.

Composite Attribute

An attribute can also have their own attributes. These attributes are known as Composite attributes.

Relationships between Entities - Weak and Strong

Rhombus is used to setup relationships between two or more entities.

There are three types of relationship that exist between Entities.


1. Binary Relationship
2. Recursive Relationship
3. Ternary Relationship

Binary Relationship

Binary Relationship means relation between two Entities.

One to One Relationship

The above example describes that one student can enroll only for one course and a course will also have only one Student. It can also be
represented using arrows.
One to Many Relationship

The below example showcases this relationship, which means that 1 student can opt for many courses, but a course can only have 1
student.

Many to One Relationship

It reflects business rule that many entities can be associated with just one entity. For example, Student enrolls for only one Course but a
Course can have many Students.

Many to Many Relationship

The above diagram represents that one student can enroll for more than one courses. And a course can have more than 1 student enrolled
in it.

Recursive Relationship

When an Entity is related with itself it is known as Recursive Relationship.

Ternary Relationship

Relationship of degree three is called Ternary relationship.


A Ternary relationship involves three entities. In such relationships we always consider two entities together and then look upon the third.

Generalization

Generalization is a bottom-up approach in which two lower level entities combine to form a higher level entity.

There are similarities between the customer entity set and the employee entity set in the sense that they have several attributes in
common. This commonality can be
expressed by generalization, which is a containment relationship that exists between a higher-level entity set and one or more lower-level
entity sets.
In this example, person is the higher-level entity set and customer and employee are lower-level entity sets.
Higher- and lower-level entity sets also may be designated by the terms superclass and subclass, respectively. The person entity set is the
superclass of the customer and employee subclasses.

Specialization

Specialization is opposite to Generalization. It is a top-down approach in which one higher level entity can be broken down into two lower
level entity. An entity set may include subgroupings of entities that are distinct in some way from other entities in the set. The process of
designating subgroupings within an entity set is called specialization. Consider an entity set person, with attributes name, street, and city.
A person may be further classified as one of the following:
• customer
• employee
The specialization of person allows us to distinguish among persons according to whether they are employees or customers.

Aggregation

Aggregation is a process when relation between two entities is treated as a single entity.
Application of Concept/ Examples in real life
E-R Diagram for Banking Enterprise (scope for modification in this ER dia)

E-R Diagram for Library Management System(modify this sample diagram to cover all the aspects of Library Management System)

You might also like