SlideShare a Scribd company logo
Database Management System (DBMS)
Sanjivani Rural Education Society’s
Sanjivani College of Engineering, Kopargaon-423603
(An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune)
NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified
Department of Information Technology
(NBA Accredited)
Mr. R. N. Kankrale
Assistant Professor
SY IT
Entity-Relationship Model
• ER diagram or Entity Relationship diagram is a conceptual model
that gives the graphical representation of the logical structure of the
database.
• It shows all the constraints and relationships that exist among the
different components.
• https://www.gatevidyalay.com/er-diagrams/
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Components of ER diagram
• An ER diagram is mainly composed of following three components-
• Entity Sets
• Attributes
• Relationship Set
• Example-
Consider the following Student table-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Roll_no Name Age
1 Akshay 20
2 Rahul 19
3 Pooja 20
4 Aarti 19
This complete table is referred to as “Student
Entity Set” and each row represents an
“entity”.
Representation as ER Diagram-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Roll_no is a primary key that can identify each entity uniquely.
Thus, by using student’s roll number, a student can be identified uniquely.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
1. For Entity Sets-
An entity set is a set of same type of entities.
An entity refers to any object having-
•Either a physical existence such as a particular person, office, house or
car.
•Or a conceptual existence such as a school or a company.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
1. Strong Entity Set-
A strong entity set possess its own primary key.
It is represented using a single rectangle.
2. Weak Entity Set-
A weak entity set do not possess its own primary key.
It is represented using a double rectangle.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
2. For Relationship Sets-
•Relationship defines an association among several entities.
•A relationship set is a set of same type of relationships.
A relationship set may be of the following two types-
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
. Strong Relationship Set-
•A strong relationship exists between two strong entity sets.
•It is represented using a diamond symbol.
2. Weak Relationship Set-
•A weak or identifying relationship exists between the strong and weak entity set.
•It is represented using a double diamond symbol.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
3. For Attributes-
•Attributes are the properties which describes the entities of an entity set.
•There are several types of attributes.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
3. For Attributes-
•Attributes are the properties which
describes the entities of an entity set.
•There are several types of attributes.
1.Simple attributes
2.Composite attributes
3.Single valued attributes
4.Multi valued attributes
5.Derived attributes
6.Key attributes
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
1. Simple Attributes-
Simple attributes are those attributes which can not be divided further.
Here, all the attributes are simple
attributes as they can not be divided
further.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
2. Composite Attributes-
Composite attributes are those attributes which are
composed of many other simple attributes.
Here, the attributes “Name”
and “Address” are composite
attributes as they are
composed of many other
simple attributes.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
3. Single Valued Attributes-
Single valued attributes are those attributes which can take only one value for a given entity from an
entity set.
Here, all the attributes are single valued attributes as they can take
only one specific value for each entity.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
4. Multi Valued Attributes-
Multi valued attributes are those attributes which can take more than one value for a given entity from an
entity set.
Here, the attributes “Mob_no” and “Email_id” are multi valued attributes
as they can take more than one values for a given entity.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
5. Derived Attributes-
Derived attributes are those attributes which can be derived from other attribute(s).
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
6. Key Attributes-
Key attributes are those attributes which can identify an entity uniquely in an entity set.
Here, the attribute “Roll_no” is a key attribute as it can identify any student
uniquely.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
4. For Participation Constraints-
Participation constraint defines the least number of relationship
instances in which an entity has to necessarily participate.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
1. Total Participation-
•It specifies that each entity in the entity set must compulsorily participate in at
least one relationship instance in that relationship set.
•That is why, it is also called as mandatory participation.
•Total participation is represented using a double line between the entity set and
relationship set.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Here,
•Double line between the entity set “Student” and relationship
set “Enrolled in” signifies total participation.
•It specifies that each student must be enrolled in at least one
course.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
2. Partial Participation-
•It specifies that each entity in the entity set may or may not participate in
the relationship instance in that relationship set.
•That is why, it is also called as optional participation.
•Partial participation is represented using a single line between the entity
set and relationship set.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Here,
•Single line between the entity set “Course” and relationship set
“Enrolled in” signifies partial participation.
•It specifies that there might exist some courses for which no
enrollments are made.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Relationship between Cardinality and Participation
Constraints-
Minimum cardinality tells whether the participation is partial or
total.
•If minimum cardinality = 0, then it signifies partial
participation.
•If minimum cardinality = 1, then it signifies total participation.
Maximum cardinality tells the maximum number of entities that
participates in a relationship set.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
6. For Cardinality Constraints / Ratios-
Cardinality constraint defines the maximum number
of relationship instances in which an entity can
participate.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
1. Many-to-Many Cardinality-
By this cardinality constraint,
•An entity in set A can be associated with any number (zero or more) of
entities in set B.
•An entity in set B can be associated with any number (zero or more) of
entities in set A.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Example-
Here,
•One student can enroll in any number (zero or more) of courses.
•One course can be enrolled by any number (zero or more) of
students.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
2. Many-to-One Cardinality-
By this cardinality constraint,
•An entity in set A can be associated with at most one entity in set B.
•An entity in set B can be associated with any number (zero or more) of entities
in set A.
Representation as ER Diagram-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Example-
Consider the following ER diagram-
Here,
•One student can enroll in at most one course.
•One course can be enrolled by any number (zero or more) of
students.
Representation as ER Diagram-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
3. One-to-Many
Cardinality-
By this cardinality
constraint,
•An entity in set A can be
associated with any
number (zero or more) of
entities in set B.
•An entity in set B can be
associated with at most
one entity in set A.
Symbol Used-
Representation as ER Diagram-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Example-
Consider the following ER diagram-
Here,
•One student can enroll in any number (zero or more) of courses.
•One course can be enrolled by at most one student.
Representation as ER Diagram-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
4. One-to-One Cardinality-
By this cardinality constraint,
•An entity in set A can be associated with at most one entity in
set B.
•An entity in set B can be associated with at most one entity in
set A.
•Symbol Used-
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Example-
Consider the following ER diagram-
Here,
•One student can enroll in at most one course.
•One course can be enrolled by at most one student.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
5. For Specialization and
Generalization-
•Generalization is a process of
forming a generalized super class
by extracting the common
characteristics from two or more
classes.
•Specialization is a reverse process
of generalization where a super
class is divided into sub classes by
assigning the specific
characteristics of sub classes to
them.
Draw of ER model
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
https://www.tutorialspoint.com/construct-an-er-diagram-for-a-company-in-d
bms
Problem
Draw of ER model for company considering the following constraints −
In a company, an employee works on many projects which are controlled by
one department.
•One employee supervises many employees.
•An employee has one or more dependents.
•One employee manages one department.
Draw of ER model
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Solution
Follow the steps given below to draw an ER model for the company −
Step 1 − Identify the entity sets
The entity set has multiple instances in a given business scenario.
As per the given constraints the entity sets are as follows:
•Employee
•Department
•Project
•Dependent
Draw of ER model
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Step 2 − Identify the attributes for the given entities
•Employee The relevant attributes are name, ssn, sex, address,
−
salary.
•Department The relevant attributes are Name, number of
−
employees, location.
•Project The relevant attributes are number, name, location.
−
•Dependent The relevant attributes are name, sex, birth date,
−
relationship.
Draw of ER model
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Step 2 − Identify the attributes for the given entities
•Employee The relevant attributes are name, ssn, sex,
−
address, salary.
•Department The relevant attributes are Name, number
−
of employees, location.
•Project The relevant attributes are number, name,
−
location.
•Dependent The relevant attributes are name, sex, birth
−
date, relationship.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Step 3 − Identify the Key attributes
•SSN is the key attribute for Employee.
•Number is the key attribute for the Department.
•Number is the key attribute for Project.
•Name is the key attribute for a dependent entity.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Step 4 − Identify the relationship between entity sets
Multiple employees work for a single department and
one department has multiple employees. Hence, the
relationship between employee and department is many
to one.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Single employee manages the entire department
and one department is handled by one manager.
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Each department is controlled by the number of
projects and the number of projects handled by
a single department. Hence, the relationship
between department and project is one-to-
many..
ER Diagram Symbols-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
The Music Database
https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html
The music database stores details of a personal music library, and could be
used to manage your MP3, CD, or vinyl collection. Because this database is for
a personal collection, it’s relatively simple and stores only the relationships
between artists, albums, and tracks. It ignores the requirements of many music
genres, making it most useful for storing popular music and less useful for
storing jazz or classical music.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
We first draw up a clear list of requirements for our database:
•The collection consists of albums.
•An album is made by exactly one artist.
•An artist makes one or more albums.
•An album contains one or more tracks
•Artists, albums, and tracks each have a name.
•Each track is on exactly one album.
•Each track has a time length, measured in seconds.
•When a track is played, the date and time the playback began
(to the nearest second) should be recorded; this is used for
reporting when a track was last played, as well as the number of
times music by an artist, from an album, or a track has been
played.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
You’ll notice that it consists of only one-to-many relationships:
one artist can make many albums, one album can contain many
tracks, and one track can be played many times. Conversely, each
play is associated with one track, a track is on one album, and an
album is by one artist. The attributes are straightforward: artists,
albums, and tracks have names, as well as identifiers to uniquely
identify each entity. The track entity has a time attribute to store
the duration, and the played entity has a timestamp to store when
the track was played.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html
The University Database
The university database stores details about university students, courses, the
semester a student took a particular course (and his mark and grade if he
completed it), and what degree program each student is enrolled in. The
database is a long way from one that’d be suitable for a large tertiary
institution, but it does illustrate relationships that are interesting to query,
and it’s easy to relate to when you’re learning SQL. We explain the
requirements next and discuss their shortcomings at the end of this section.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html
Consider the following requirements list:
The university offers one or more programs.
A program is made up of one or more courses.
A student must enroll in a program.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html
A student takes the courses that are part of her program.
A program has a name, a program identifier, the total credit points
required to graduate, and the year it commenced.
A course has a name, a course identifier, a credit point value, and the
year it commenced.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html
Students have one or more given names, a surname, a student identifier,
a date of birth, and the year they first enrolled. We can treat all given
names as a single object—for example, “John Paul.”
When a student takes a course, the year and semester he attempted it
are recorded. When he finishes the course, a grade (such as A or B) and a
mark (such as 60 percent) are recorded.
Each course in a program is sequenced into a year (for example, year 1)
and a semester (for example, semester 1).
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
The Flight Database
The flight database stores details about an airline’s fleet, flights, and
seat bookings. Again, it’s a hugely simplified version of what a real
airline would use, but the principles are the same.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Consider the following requirements list:
•The airline has one or more airplanes.
•An airplane has a model number, a unique registration number, and the
capacity to take one or more passengers.
•An airplane flight has a unique flight number, a departure airport, a
destination airport, a departure date and time, and an arrival date and time.
•Each flight is carried out by a single airplane.
•A passenger has given names, a surname, and a unique email address.
•A passenger can book a seat on a flight.
Representation as ER Diagram-
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
• In a university, a Student enrolls in Courses. A student must be
assigned to at least one or more Courses. Each course is taught
by a single Professor. To maintain instruction quality, a Professor
can deliver only one course
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
Step 1) Entity Identification
We have three entities
•Student
•Course
Professor
Step 2) Relationship Identification
We have the following two relationships
•The student is assigned a course
•Professor delivers a course
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
Step 3) Cardinality Identification
For them problem statement we know that,
•A student can be assigned multiple courses
•A Professor can deliver only one course
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
Step 4) Identify Attributes
You need to study the files, forms, reports, data currently maintained
by the organization to identify attributes. You can also conduct
interviews with various stakeholders to identify entities. Initially, it’s
important to identify the attributes without mapping them to a
particular entity.
Once, you have a list of Attributes, you need to map them to the
identified entities. Ensure an attribute is to be paired with exactly one
entity. If you think an attribute should belong to more than one entity,
use a modifier to make it unique.
Once the mapping is done, identify the primary Keys. If a unique key is
not readily available, create one.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
Entity Primary Key Attribute
Student Student_ID StudentName
Professor Employee_ID ProfessorName
Course Course_ID CourseName
Once the mapping is done, identify the primary Keys. If a unique key
is not readily available, create one.
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
Entity Relationship Modeling Examples
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
• https://www.guru99.com/er-diagram-tutorial-dbms.html
Best Practices for Developing Effective ER Diagrams
• Eliminate any redundant entities or relationships
• You need to make sure that all your entities and relationships are
properly labeled
• There may be various valid approaches to an ER diagram. You need to
make sure that the ER diagram supports all the data you need to store
• You should assure that each entity only appears a single time in the ER
diagram
• Name every relationship, entity, and attribute are represented on your
diagram
• Never connect relationships to each other
• You should use colors to highlight important portions of the ER
diagram
Entity-Relationship Model
 Design Process
 Modeling
 Constraints
 E-R Diagram
 Design Issues
 Weak Entity Sets
 Extended E-R Features
 Design of the Bank Database
 Reduction to Relation Schemas
 Database Design
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Design Approaches
 Entity Relationship Model (covered in this chapter)
 Models an enterprise as a collection of entities and relationships
 Entity: a “thing” or “object” in the enterprise that is distinguishable from other objects
– Described by a set of attributes
 Relationship: an association among several entities
 Represented diagrammatically by an entity-relationship diagram:
 Normalization Theory
 Formalize what designs are bad, and test for them
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
ER model -- Database Modeling
 The ER data mode was developed to facilitate database design by allowing specification of an enterprise
schema that represents the overall logical structure of a database.
 The ER model is very useful in mapping the meanings and interactions of real-world enterprises onto a
conceptual schema. Because of this usefulness, many database-design tools draw on concepts from the ER
model.
 The ER data model employs three basic concepts:
 entity sets,
 relationship sets,
 attributes.
 The ER model also has an associated diagrammatic representation, the ER diagram, which can express the
overall logical structure of a database graphically.
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Entity Sets
 An entity is an object that exists and is distinguishable from other objects.
 Example: specific person, company, event, plant
 An entity set is a set of entities of the same type that share the same properties.
 Example: set of all persons, companies, trees, holidays
 An entity is represented by a set of attributes; i.e., descriptive properties possessed by all members of an
entity set.
 Example:
 instructor = (ID, name, street, city, salary )
course= (course_id, title, credits)
 A subset of the attributes form a primary key of the entity set; i.e., uniquely identifiying each member of the
set.
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Entity Sets -- instructor and student
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
instructor_ID instructor_name student-ID student_name
Relationship Sets
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 A relationship is an association among several entities
Example:
44553 (Peltier) advisor 22222 (Einstein)
student entity relationship set instructor entity
 A relationship set is a mathematical relation among n  2 entities, each taken from
entity sets
{(e1, e2, … en) | e1  E1, e2  E2, …, en  En}
where (e1, e2, …, en) is a relationship
 Example:
(44553,22222)  advisor
Relationship Set advisor
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Relationship Sets (Cont.)
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 An attribute can also be associated with a relationship set.
 For instance, the advisor relationship set between entity sets instructor and student may have the
attribute date which tracks when the student started being associated with the advisor
Degree of a Relationship Set
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 binary relationship
 involve two entity sets (or degree two).
 most relationship sets in a database system are binary.
 Relationships between more than two entity sets are rare. Most relationships are binary. (More
on this later.)
 Example: students work on research projects under the guidance of an instructor.
 relationship proj_guide is a ternary relationship between instructor, student, and project
Mapping Cardinality Constraints
Mapping Cardinality Constraints
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 Express the number of entities to which another entity can be associated via a relationship set.
 Most useful in describing binary relationship sets.
 For a binary relationship set the mapping cardinality must be one of the following types:
 One to one
 One to many
 Many to one
 Many to many
Mapping Cardinalities
Mapping Cardinalities
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Note: Some elements in A and B may not be mapped to any
elements in the other set
One to one One to many
Mapping Cardinalities
Mapping Cardinalities
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Note: Some elements in A and B may not be mapped to any
elements in the other set
many to one many to many
Complex Attributes
Complex Attributes
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 Attribute types:
 Simple and composite attributes.
 Single-valued and multivalued attributes
 Example: multivalued attribute: phone_numbers
 Derived attributes
 Can be computed from other attributes
 Example: age, given date_of_birth
 Domain – the set of permitted values for each attribute
Composite Attributes
Composite Attributes
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Redundant Attributes
Redundant Attributes
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 Suppose we have entity sets:
 instructor, with attributes: ID, name, dept_name, salary
 department, with attributes: dept_name, building, budget
 We model the fact that each instructor has an associated department using a
relationship set inst_dept
 The attribute dept_name appears in both entity sets. Since it is the primary key
for the entity set department, it replicates information present in the relationship
and is therefore redundant in the entity set instructor and needs to be removed.
 BUT: when converting back to tables, in some cases the attribute gets
reintroduced, as we will see later.
Weak Entity Sets
Weak Entity Sets
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 Consider a section entity, which is uniquely identified by a course_id, semester, year,
and sec_id.
 Clearly, section entities are related to course entities. Suppose we create a
relationship set sec_course between entity sets section and course.
 Note that the information in sec_course is redundant, since section already has an
attribute course_id, which identifies the course with which the section is related.
 One option to deal with this redundancy is to get rid of the relationship sec_course;
however, by doing so the relationship between section and course becomes implicit
in an attribute, which is not desirable
Weak Entity Sets (Cont.)
Weak Entity Sets (Cont.)
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 An alternative way to deal with this redundancy is to not store the attribute course_id in the
section entity and to only store the remaining attributes section_id, year, and semester.
However, the entity set section then does not have enough attributes to identify a
particular section entity uniquely; although each section entity is distinct, sections for
different courses may share the same section_id, year, and semester.
 To deal with this problem, we treat the relationship sec_course as a special relationship
that provides extra information, in this case, the course_id, required to identify section
entities uniquely.
 The notion of weak entity set formalizes the above intuition. A weak entity set is one
whose existence is dependent on another entity, called its identifying entity; instead of
associating a primary key with a weak entity, we use the identifying entity, along with extra
attributes called discriminator to uniquely identify a weak entity. An entity set that is not a
weak entity set is termed a strong entity set.
Weak Entity Sets (Cont.)
Weak Entity Sets (Cont.)
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 Every weak entity must be associated with an identifying entity; that is, the weak entity set
is said to be existence dependent on the identifying entity set. The identifying entity set is
said to own the weak entity set that it identifies. The relationship associating the weak
entity set with the identifying entity set is called the identifying relationship.
 Note that the relational schema we eventually create from the entity set section does have
the attribute course_id, for reasons that will become clear later, even though we have
dropped the attribute course_id from the entity set section.
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
E-R Diagrams
E-R Diagrams
Entity Sets
Entity Sets
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
Entities can be represented graphically as follows:
•Rectangles represent entity sets.
•Attributes listed inside entity rectangle
•Underline indicates primary key attributes
Relationship Sets
Relationship Sets
DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
 Diamonds represent relationship sets.

More Related Content

PDF
Advantages and disadvantages of er model in DBMS. Types of database models ..
PPTX
Entity_DBMS.pptx
PPTX
Database Design and Entity relationship Model.pptx
DOCX
ER Diagram_Kameshwari.docx
PPT
Unit 2 ER Model.ppterfgmefwlgmkldfsmglkdfg
ODP
ER Model in DBMS
PPTX
ER-Diagram.pptx , ER diagram , entity reltaionship diagram , data base
PPTX
Er model
Advantages and disadvantages of er model in DBMS. Types of database models ..
Entity_DBMS.pptx
Database Design and Entity relationship Model.pptx
ER Diagram_Kameshwari.docx
Unit 2 ER Model.ppterfgmefwlgmkldfsmglkdfg
ER Model in DBMS
ER-Diagram.pptx , ER diagram , entity reltaionship diagram , data base
Er model

Similar to UNIT 1 ER Model 2025 -Entity Relationship (ER) Diagram (20)

PDF
Introduction to database-ER Model
PPTX
Module2 Data Base Design- ER and NF.pptx
PPTX
PPTX
DBMS Unit-2_Final.pptx
PPT
ermodelN in database management system.ppt
PDF
dbms mannual.pdf
PPTX
E-R Diagram and their models using datbase
PPTX
COMPUTER PROGRAMMING-LESSON3-ENTITY.pptx
PPTX
Entity Relationship Diagram – ER Diagram in DBMS.pptx
PPTX
Entity Relationship Diagram – ER Diagram in DBMS.pptx
PPTX
ER-Diagram.pptx
PDF
Unit1 rdbms study_materials-converted (1) (1)
PDF
Unit1 rdbms study_materials
PPTX
DBMS Conceptual Design using ER Model.pptx
PPTX
Entity Relationship Model in Database System
PPTX
Introduction to ER Diagrams
PPTX
Chapter 4_ERD- introduction to entity relationship diagram.pptx
PDF
Assignment#03
PDF
Unit 2 DBMS
PPTX
entityrelationshipmodel.pptx
Introduction to database-ER Model
Module2 Data Base Design- ER and NF.pptx
DBMS Unit-2_Final.pptx
ermodelN in database management system.ppt
dbms mannual.pdf
E-R Diagram and their models using datbase
COMPUTER PROGRAMMING-LESSON3-ENTITY.pptx
Entity Relationship Diagram – ER Diagram in DBMS.pptx
Entity Relationship Diagram – ER Diagram in DBMS.pptx
ER-Diagram.pptx
Unit1 rdbms study_materials-converted (1) (1)
Unit1 rdbms study_materials
DBMS Conceptual Design using ER Model.pptx
Entity Relationship Model in Database System
Introduction to ER Diagrams
Chapter 4_ERD- introduction to entity relationship diagram.pptx
Assignment#03
Unit 2 DBMS
entityrelationshipmodel.pptx
Ad

More from RajendraKankrale1 (7)

PPTX
5.Transaction Management and concurrency Control
PPTX
PL_SQL, Trigger, Cursor, Stored procedure ,function
PPT
UNIT 2 relational algebra and Structured Query Language
PPTX
HADOOP ECO SYSTEM Pig: Introduction to PIG, Execution Modes of Pig, Comp...
PPTX
INTRODUCTION TO APACHE HADOOP AND MAPREDUCE
PPTX
Unit2_Regression, ADVANCED ANALYTICAL THEORY AND METHODS USING PYTHON
PPTX
Unit-I_Big data life cycle.pptx, sources of Big Data
5.Transaction Management and concurrency Control
PL_SQL, Trigger, Cursor, Stored procedure ,function
UNIT 2 relational algebra and Structured Query Language
HADOOP ECO SYSTEM Pig: Introduction to PIG, Execution Modes of Pig, Comp...
INTRODUCTION TO APACHE HADOOP AND MAPREDUCE
Unit2_Regression, ADVANCED ANALYTICAL THEORY AND METHODS USING PYTHON
Unit-I_Big data life cycle.pptx, sources of Big Data
Ad

Recently uploaded (20)

PDF
PPT on Performance Review to get promotions
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Artificial Intelligence
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Construction Project Organization Group 2.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
composite construction of structures.pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPT
Project quality management in manufacturing
PDF
Well-logging-methods_new................
PPTX
Sustainable Sites - Green Building Construction
PPT
Mechanical Engineering MATERIALS Selection
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT on Performance Review to get promotions
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Safety Seminar civil to be ensured for safe working.
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Artificial Intelligence
bas. eng. economics group 4 presentation 1.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Lecture Notes Electrical Wiring System Components
Construction Project Organization Group 2.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
composite construction of structures.pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Project quality management in manufacturing
Well-logging-methods_new................
Sustainable Sites - Green Building Construction
Mechanical Engineering MATERIALS Selection
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx

UNIT 1 ER Model 2025 -Entity Relationship (ER) Diagram

  • 1. Database Management System (DBMS) Sanjivani Rural Education Society’s Sanjivani College of Engineering, Kopargaon-423603 (An Autonomous Institute Affiliated to Savitribai Phule Pune University, Pune) NACC ‘A’ Grade Accredited, ISO 9001:2015 Certified Department of Information Technology (NBA Accredited) Mr. R. N. Kankrale Assistant Professor SY IT
  • 2. Entity-Relationship Model • ER diagram or Entity Relationship diagram is a conceptual model that gives the graphical representation of the logical structure of the database. • It shows all the constraints and relationships that exist among the different components. • https://www.gatevidyalay.com/er-diagrams/ DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 3. Components of ER diagram • An ER diagram is mainly composed of following three components- • Entity Sets • Attributes • Relationship Set • Example- Consider the following Student table- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Roll_no Name Age 1 Akshay 20 2 Rahul 19 3 Pooja 20 4 Aarti 19 This complete table is referred to as “Student Entity Set” and each row represents an “entity”.
  • 4. Representation as ER Diagram- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Roll_no is a primary key that can identify each entity uniquely. Thus, by using student’s roll number, a student can be identified uniquely.
  • 5. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 1. For Entity Sets- An entity set is a set of same type of entities. An entity refers to any object having- •Either a physical existence such as a particular person, office, house or car. •Or a conceptual existence such as a school or a company.
  • 6. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 1. Strong Entity Set- A strong entity set possess its own primary key. It is represented using a single rectangle. 2. Weak Entity Set- A weak entity set do not possess its own primary key. It is represented using a double rectangle.
  • 7. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 2. For Relationship Sets- •Relationship defines an association among several entities. •A relationship set is a set of same type of relationships. A relationship set may be of the following two types-
  • 8. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology . Strong Relationship Set- •A strong relationship exists between two strong entity sets. •It is represented using a diamond symbol. 2. Weak Relationship Set- •A weak or identifying relationship exists between the strong and weak entity set. •It is represented using a double diamond symbol.
  • 9. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 3. For Attributes- •Attributes are the properties which describes the entities of an entity set. •There are several types of attributes.
  • 10. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 3. For Attributes- •Attributes are the properties which describes the entities of an entity set. •There are several types of attributes. 1.Simple attributes 2.Composite attributes 3.Single valued attributes 4.Multi valued attributes 5.Derived attributes 6.Key attributes
  • 11. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 1. Simple Attributes- Simple attributes are those attributes which can not be divided further. Here, all the attributes are simple attributes as they can not be divided further.
  • 12. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 2. Composite Attributes- Composite attributes are those attributes which are composed of many other simple attributes. Here, the attributes “Name” and “Address” are composite attributes as they are composed of many other simple attributes.
  • 13. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 3. Single Valued Attributes- Single valued attributes are those attributes which can take only one value for a given entity from an entity set. Here, all the attributes are single valued attributes as they can take only one specific value for each entity.
  • 14. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 4. Multi Valued Attributes- Multi valued attributes are those attributes which can take more than one value for a given entity from an entity set. Here, the attributes “Mob_no” and “Email_id” are multi valued attributes as they can take more than one values for a given entity.
  • 15. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 5. Derived Attributes- Derived attributes are those attributes which can be derived from other attribute(s).
  • 16. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 6. Key Attributes- Key attributes are those attributes which can identify an entity uniquely in an entity set. Here, the attribute “Roll_no” is a key attribute as it can identify any student uniquely.
  • 17. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 4. For Participation Constraints- Participation constraint defines the least number of relationship instances in which an entity has to necessarily participate.
  • 18. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 19. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 1. Total Participation- •It specifies that each entity in the entity set must compulsorily participate in at least one relationship instance in that relationship set. •That is why, it is also called as mandatory participation. •Total participation is represented using a double line between the entity set and relationship set.
  • 20. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Here, •Double line between the entity set “Student” and relationship set “Enrolled in” signifies total participation. •It specifies that each student must be enrolled in at least one course.
  • 21. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 2. Partial Participation- •It specifies that each entity in the entity set may or may not participate in the relationship instance in that relationship set. •That is why, it is also called as optional participation. •Partial participation is represented using a single line between the entity set and relationship set.
  • 22. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Here, •Single line between the entity set “Course” and relationship set “Enrolled in” signifies partial participation. •It specifies that there might exist some courses for which no enrollments are made.
  • 23. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Relationship between Cardinality and Participation Constraints- Minimum cardinality tells whether the participation is partial or total. •If minimum cardinality = 0, then it signifies partial participation. •If minimum cardinality = 1, then it signifies total participation. Maximum cardinality tells the maximum number of entities that participates in a relationship set.
  • 24. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 6. For Cardinality Constraints / Ratios- Cardinality constraint defines the maximum number of relationship instances in which an entity can participate.
  • 25. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 26. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 1. Many-to-Many Cardinality- By this cardinality constraint, •An entity in set A can be associated with any number (zero or more) of entities in set B. •An entity in set B can be associated with any number (zero or more) of entities in set A.
  • 27. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Example- Here, •One student can enroll in any number (zero or more) of courses. •One course can be enrolled by any number (zero or more) of students.
  • 28. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 2. Many-to-One Cardinality- By this cardinality constraint, •An entity in set A can be associated with at most one entity in set B. •An entity in set B can be associated with any number (zero or more) of entities in set A.
  • 29. Representation as ER Diagram- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Example- Consider the following ER diagram- Here, •One student can enroll in at most one course. •One course can be enrolled by any number (zero or more) of students.
  • 30. Representation as ER Diagram- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 3. One-to-Many Cardinality- By this cardinality constraint, •An entity in set A can be associated with any number (zero or more) of entities in set B. •An entity in set B can be associated with at most one entity in set A. Symbol Used-
  • 31. Representation as ER Diagram- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Example- Consider the following ER diagram- Here, •One student can enroll in any number (zero or more) of courses. •One course can be enrolled by at most one student.
  • 32. Representation as ER Diagram- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 4. One-to-One Cardinality- By this cardinality constraint, •An entity in set A can be associated with at most one entity in set B. •An entity in set B can be associated with at most one entity in set A. •Symbol Used-
  • 33. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Example- Consider the following ER diagram- Here, •One student can enroll in at most one course. •One course can be enrolled by at most one student.
  • 34. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology 5. For Specialization and Generalization- •Generalization is a process of forming a generalized super class by extracting the common characteristics from two or more classes. •Specialization is a reverse process of generalization where a super class is divided into sub classes by assigning the specific characteristics of sub classes to them.
  • 35. Draw of ER model DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology https://www.tutorialspoint.com/construct-an-er-diagram-for-a-company-in-d bms Problem Draw of ER model for company considering the following constraints − In a company, an employee works on many projects which are controlled by one department. •One employee supervises many employees. •An employee has one or more dependents. •One employee manages one department.
  • 36. Draw of ER model DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Solution Follow the steps given below to draw an ER model for the company − Step 1 − Identify the entity sets The entity set has multiple instances in a given business scenario. As per the given constraints the entity sets are as follows: •Employee •Department •Project •Dependent
  • 37. Draw of ER model DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Step 2 − Identify the attributes for the given entities •Employee The relevant attributes are name, ssn, sex, address, − salary. •Department The relevant attributes are Name, number of − employees, location. •Project The relevant attributes are number, name, location. − •Dependent The relevant attributes are name, sex, birth date, − relationship.
  • 38. Draw of ER model DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Step 2 − Identify the attributes for the given entities •Employee The relevant attributes are name, ssn, sex, − address, salary. •Department The relevant attributes are Name, number − of employees, location. •Project The relevant attributes are number, name, − location. •Dependent The relevant attributes are name, sex, birth − date, relationship.
  • 39. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Step 3 − Identify the Key attributes •SSN is the key attribute for Employee. •Number is the key attribute for the Department. •Number is the key attribute for Project. •Name is the key attribute for a dependent entity.
  • 40. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Step 4 − Identify the relationship between entity sets Multiple employees work for a single department and one department has multiple employees. Hence, the relationship between employee and department is many to one.
  • 41. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Single employee manages the entire department and one department is handled by one manager.
  • 42. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Each department is controlled by the number of projects and the number of projects handled by a single department. Hence, the relationship between department and project is one-to- many..
  • 43. ER Diagram Symbols- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 44. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology The Music Database https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html The music database stores details of a personal music library, and could be used to manage your MP3, CD, or vinyl collection. Because this database is for a personal collection, it’s relatively simple and stores only the relationships between artists, albums, and tracks. It ignores the requirements of many music genres, making it most useful for storing popular music and less useful for storing jazz or classical music.
  • 45. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology We first draw up a clear list of requirements for our database: •The collection consists of albums. •An album is made by exactly one artist. •An artist makes one or more albums. •An album contains one or more tracks •Artists, albums, and tracks each have a name. •Each track is on exactly one album. •Each track has a time length, measured in seconds. •When a track is played, the date and time the playback began (to the nearest second) should be recorded; this is used for reporting when a track was last played, as well as the number of times music by an artist, from an album, or a track has been played.
  • 46. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology You’ll notice that it consists of only one-to-many relationships: one artist can make many albums, one album can contain many tracks, and one track can be played many times. Conversely, each play is associated with one track, a track is on one album, and an album is by one artist. The attributes are straightforward: artists, albums, and tracks have names, as well as identifiers to uniquely identify each entity. The track entity has a time attribute to store the duration, and the played entity has a timestamp to store when the track was played.
  • 47. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 48. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html The University Database The university database stores details about university students, courses, the semester a student took a particular course (and his mark and grade if he completed it), and what degree program each student is enrolled in. The database is a long way from one that’d be suitable for a large tertiary institution, but it does illustrate relationships that are interesting to query, and it’s easy to relate to when you’re learning SQL. We explain the requirements next and discuss their shortcomings at the end of this section.
  • 49. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html Consider the following requirements list: The university offers one or more programs. A program is made up of one or more courses. A student must enroll in a program.
  • 50. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html A student takes the courses that are part of her program. A program has a name, a program identifier, the total credit points required to graduate, and the year it commenced. A course has a name, a course identifier, a credit point value, and the year it commenced.
  • 51. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html Students have one or more given names, a surname, a student identifier, a date of birth, and the year they first enrolled. We can treat all given names as a single object—for example, “John Paul.” When a student takes a course, the year and semester he attempted it are recorded. When he finishes the course, a grade (such as A or B) and a mark (such as 60 percent) are recorded. Each course in a program is sequenced into a year (for example, year 1) and a semester (for example, semester 1).
  • 52. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology https://www.oreilly.com/library/view/learning-mysql/0596008643/ch04s04.html
  • 53. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology The Flight Database The flight database stores details about an airline’s fleet, flights, and seat bookings. Again, it’s a hugely simplified version of what a real airline would use, but the principles are the same.
  • 54. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Consider the following requirements list: •The airline has one or more airplanes. •An airplane has a model number, a unique registration number, and the capacity to take one or more passengers. •An airplane flight has a unique flight number, a departure airport, a destination airport, a departure date and time, and an arrival date and time. •Each flight is carried out by a single airplane. •A passenger has given names, a surname, and a unique email address. •A passenger can book a seat on a flight.
  • 55. Representation as ER Diagram- DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 56. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html
  • 57. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html • In a university, a Student enrolls in Courses. A student must be assigned to at least one or more Courses. Each course is taught by a single Professor. To maintain instruction quality, a Professor can deliver only one course
  • 58. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html Step 1) Entity Identification We have three entities •Student •Course Professor Step 2) Relationship Identification We have the following two relationships •The student is assigned a course •Professor delivers a course
  • 59. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html Step 3) Cardinality Identification For them problem statement we know that, •A student can be assigned multiple courses •A Professor can deliver only one course
  • 60. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html Step 4) Identify Attributes You need to study the files, forms, reports, data currently maintained by the organization to identify attributes. You can also conduct interviews with various stakeholders to identify entities. Initially, it’s important to identify the attributes without mapping them to a particular entity. Once, you have a list of Attributes, you need to map them to the identified entities. Ensure an attribute is to be paired with exactly one entity. If you think an attribute should belong to more than one entity, use a modifier to make it unique. Once the mapping is done, identify the primary Keys. If a unique key is not readily available, create one.
  • 61. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html Entity Primary Key Attribute Student Student_ID StudentName Professor Employee_ID ProfessorName Course Course_ID CourseName Once the mapping is done, identify the primary Keys. If a unique key is not readily available, create one.
  • 62. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html
  • 63. Entity Relationship Modeling Examples DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology • https://www.guru99.com/er-diagram-tutorial-dbms.html Best Practices for Developing Effective ER Diagrams • Eliminate any redundant entities or relationships • You need to make sure that all your entities and relationships are properly labeled • There may be various valid approaches to an ER diagram. You need to make sure that the ER diagram supports all the data you need to store • You should assure that each entity only appears a single time in the ER diagram • Name every relationship, entity, and attribute are represented on your diagram • Never connect relationships to each other • You should use colors to highlight important portions of the ER diagram
  • 64. Entity-Relationship Model  Design Process  Modeling  Constraints  E-R Diagram  Design Issues  Weak Entity Sets  Extended E-R Features  Design of the Bank Database  Reduction to Relation Schemas  Database Design DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 65. Design Approaches  Entity Relationship Model (covered in this chapter)  Models an enterprise as a collection of entities and relationships  Entity: a “thing” or “object” in the enterprise that is distinguishable from other objects – Described by a set of attributes  Relationship: an association among several entities  Represented diagrammatically by an entity-relationship diagram:  Normalization Theory  Formalize what designs are bad, and test for them DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 66. ER model -- Database Modeling  The ER data mode was developed to facilitate database design by allowing specification of an enterprise schema that represents the overall logical structure of a database.  The ER model is very useful in mapping the meanings and interactions of real-world enterprises onto a conceptual schema. Because of this usefulness, many database-design tools draw on concepts from the ER model.  The ER data model employs three basic concepts:  entity sets,  relationship sets,  attributes.  The ER model also has an associated diagrammatic representation, the ER diagram, which can express the overall logical structure of a database graphically. DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 67. Entity Sets  An entity is an object that exists and is distinguishable from other objects.  Example: specific person, company, event, plant  An entity set is a set of entities of the same type that share the same properties.  Example: set of all persons, companies, trees, holidays  An entity is represented by a set of attributes; i.e., descriptive properties possessed by all members of an entity set.  Example:  instructor = (ID, name, street, city, salary ) course= (course_id, title, credits)  A subset of the attributes form a primary key of the entity set; i.e., uniquely identifiying each member of the set. DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 68. Entity Sets -- instructor and student DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology instructor_ID instructor_name student-ID student_name
  • 69. Relationship Sets DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  A relationship is an association among several entities Example: 44553 (Peltier) advisor 22222 (Einstein) student entity relationship set instructor entity  A relationship set is a mathematical relation among n  2 entities, each taken from entity sets {(e1, e2, … en) | e1  E1, e2  E2, …, en  En} where (e1, e2, …, en) is a relationship  Example: (44553,22222)  advisor
  • 70. Relationship Set advisor DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 71. Relationship Sets (Cont.) DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  An attribute can also be associated with a relationship set.  For instance, the advisor relationship set between entity sets instructor and student may have the attribute date which tracks when the student started being associated with the advisor
  • 72. Degree of a Relationship Set DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  binary relationship  involve two entity sets (or degree two).  most relationship sets in a database system are binary.  Relationships between more than two entity sets are rare. Most relationships are binary. (More on this later.)  Example: students work on research projects under the guidance of an instructor.  relationship proj_guide is a ternary relationship between instructor, student, and project
  • 73. Mapping Cardinality Constraints Mapping Cardinality Constraints DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  Express the number of entities to which another entity can be associated via a relationship set.  Most useful in describing binary relationship sets.  For a binary relationship set the mapping cardinality must be one of the following types:  One to one  One to many  Many to one  Many to many
  • 74. Mapping Cardinalities Mapping Cardinalities DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Note: Some elements in A and B may not be mapped to any elements in the other set One to one One to many
  • 75. Mapping Cardinalities Mapping Cardinalities DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Note: Some elements in A and B may not be mapped to any elements in the other set many to one many to many
  • 76. Complex Attributes Complex Attributes DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  Attribute types:  Simple and composite attributes.  Single-valued and multivalued attributes  Example: multivalued attribute: phone_numbers  Derived attributes  Can be computed from other attributes  Example: age, given date_of_birth  Domain – the set of permitted values for each attribute
  • 77. Composite Attributes Composite Attributes DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology
  • 78. Redundant Attributes Redundant Attributes DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  Suppose we have entity sets:  instructor, with attributes: ID, name, dept_name, salary  department, with attributes: dept_name, building, budget  We model the fact that each instructor has an associated department using a relationship set inst_dept  The attribute dept_name appears in both entity sets. Since it is the primary key for the entity set department, it replicates information present in the relationship and is therefore redundant in the entity set instructor and needs to be removed.  BUT: when converting back to tables, in some cases the attribute gets reintroduced, as we will see later.
  • 79. Weak Entity Sets Weak Entity Sets DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  Consider a section entity, which is uniquely identified by a course_id, semester, year, and sec_id.  Clearly, section entities are related to course entities. Suppose we create a relationship set sec_course between entity sets section and course.  Note that the information in sec_course is redundant, since section already has an attribute course_id, which identifies the course with which the section is related.  One option to deal with this redundancy is to get rid of the relationship sec_course; however, by doing so the relationship between section and course becomes implicit in an attribute, which is not desirable
  • 80. Weak Entity Sets (Cont.) Weak Entity Sets (Cont.) DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  An alternative way to deal with this redundancy is to not store the attribute course_id in the section entity and to only store the remaining attributes section_id, year, and semester. However, the entity set section then does not have enough attributes to identify a particular section entity uniquely; although each section entity is distinct, sections for different courses may share the same section_id, year, and semester.  To deal with this problem, we treat the relationship sec_course as a special relationship that provides extra information, in this case, the course_id, required to identify section entities uniquely.  The notion of weak entity set formalizes the above intuition. A weak entity set is one whose existence is dependent on another entity, called its identifying entity; instead of associating a primary key with a weak entity, we use the identifying entity, along with extra attributes called discriminator to uniquely identify a weak entity. An entity set that is not a weak entity set is termed a strong entity set.
  • 81. Weak Entity Sets (Cont.) Weak Entity Sets (Cont.) DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  Every weak entity must be associated with an identifying entity; that is, the weak entity set is said to be existence dependent on the identifying entity set. The identifying entity set is said to own the weak entity set that it identifies. The relationship associating the weak entity set with the identifying entity set is called the identifying relationship.  Note that the relational schema we eventually create from the entity set section does have the attribute course_id, for reasons that will become clear later, even though we have dropped the attribute course_id from the entity set section.
  • 82. DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology E-R Diagrams E-R Diagrams
  • 83. Entity Sets Entity Sets DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology Entities can be represented graphically as follows: •Rectangles represent entity sets. •Attributes listed inside entity rectangle •Underline indicates primary key attributes
  • 84. Relationship Sets Relationship Sets DBMS – Unit-I: Part-I Mr. R. N. Kankrale Department of Information Technology  Diamonds represent relationship sets.