0% found this document useful (0 votes)
10 views72 pages

2 ERDesign

Uploaded by

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

2 ERDesign

Uploaded by

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

Chapter 2

By Amruta Navale
Conceptual Design(ER –Model)
-By Amruta Navale
OVERVIEW OF DB DESIGN ER DATA MODEL
 An entity relationship diagram (ERD) shows the relationships of entity sets
stored in a database. An entity in this context is an object, a component of
data. An entity set is a collection of similar entities. These entities can have

By Amruta Navale
attributes that define its properties.
 ER Model is used to model the logical view of the system from data
perspective which consists of these components:
 Entity Relationship Diagram, also known as ERD, ER Diagram or ER model,
is a type of structural diagram for use in database design. An ERD contains
different symbols and connectors that visualize two important
information: The major entities within the system scope, and the inter-
relationships among these entities.
 And that's why it's called "Entity" "Relationship" diagram (ERD)
ER MODEL

By Amruta Navale
 An Entity–relationship model (ER model) describes the structure of a database with the
help of a diagram, which is known as Entity Relationship Diagram (ER Diagram). An ER
model is a design or blueprint of a database that can later be implemented as a database.
The main components of E-R model are: entity set and relationship set.
 What is an Entity Relationship Diagram (ER Diagram)?
 An ER diagram shows the relationship among entity sets. An entity set is a group of similar
entities and these entities can have attributes.
 In terms of DBMS, an entity is a table or attribute of a table in database, so by showing
relationship among tables and their attributes, ER diagram shows the complete logical
structure of a database. Lets have a look at a simple ER diagram to understand this
concept.
E-R DATA MODEL

By Amruta Navale
 ER model stands for an Entity-Relationship model based on a perception of real world. The ER
model used to design the database.
 E-R model is based on the concept of real world entities and relationship between them.
 The ER model defines the conceptual view of a database.
 This model is consists of a set of basic objects called entities and relationship among these objects.
 It shows a pictorial representation of data.
 There are three basic notations used in E-R diagram:
1. Entity sets,
2. Relationship sets
3. Attributes
1. ENTITY

By Amruta Navale
 An entity is basic thing or object in ER diagram which is distinguishable from other object. It can
be a real-world object.
 In the ER diagram, an entity can represented by rectangle.
 This object has its own properties.
 This object is distinguishable from other objects.
 Student has its own properties like his/her own name, address etc
 For example, in a school database, students, teachers, classes, and courses can be entities.
ER SYMBOLS-ERD ENTITY SYMBOLS
 Entities are objects or concepts that represent important data. Entities are typically nouns such as product,
customer, location, or promotion. There are three types of entities commonly used in entity relationship
diagrams.

By Amruta Navale
ERD RELATIONSHIP SYMBOLS
 Within entity-relationship diagrams, relationships are used to document the interaction between two entities.
Relationships are usually verbs such as assign, associate, or track and provide useful information that could not be
discerned with just the entity types.

By Amruta Navale
ERD ATTRIBUTE SYMBOLS

By Amruta Navale
 ERD attributes are characteristics of the entity that help users to better understand the database.
By Amruta Navale
CONTINUE..
SIMPLE ER DIAGRAM
• Student and College and their relationship. The relationship between Student and
College is many to one as a college can have many students however a student cannot

By Amruta Navale
study in multiple colleges at the same time. Student entity has attributes such as Stu_Id,
Stu_Name & Stu_Addr and College entity has attributes such as Col_ID & Col_Name.
By Amruta Navale
2. ENTITY SET
 An entity set is a collection of similar types of entities. An entity set may contain entities with
attribute sharing similar values.
 An entity set is a collection of similar types of entities. An entity set may contain entities with

By Amruta Navale
attribute sharing similar values.
 For example, a Students set may contain all the students of a school; likewise a Teachers set
may contain all the teachers of a school from all faculties.
 For example, a Students set may contain all the students of a school;
3. ATTRIBUTES
 The attribute is used to describe the property or characteristics of an entity.
Ellipse symbol is used to represent an attribute.

By Amruta Navale
 E.g. Roll no, age, contact number, name, etc. can be attributes of a student.
There exists a domain or range of values that can be assigned to attributes.
 For example, a student's name cannot be a numeric value. It has to be
alphabetic. A student's age cannot be negative, etc.
TYPES OF ATTRIBUTES
1. Simple or atomic attribute:
 Simple attributes are atomic values, which cannot be divided further.

By Amruta Navale
 For example, a student's Roll number is an atomic value.
By Amruta Navale
2. Composite attribute
 Composite attributes are those attributes that are divided into smaller subparts. Composite
attributes are made of more than one simple attribute.
 For example, In student entity, the student address is a composite attribute as an address is
composed of other attributes such as pin code, state, country .
3. Stored and Derived attribute
 The value of this attribute can be derived from values of other stored attributed of

By Amruta Navale
entities.
 Stored attributes are the attributes that exist in the physical database .
 For example , date_of_birth.
 Derived attribute − Derived attributes are the attributes that do not exist in the
physical database, but their values are derived from other attributes present in the
database.
 It is represented by dashed ellipse.
By Amruta Navale
By Amruta Navale
4. Single-value attribute
 The attribute which contains one value for a specific entity in their column is called single
value attributed.
 For example: Roll_no, Age,DOB, Gender mount has only one value.
5. Multi-valued attribute
 Multi-value attributes may contain more than one values.

By Amruta Navale
 For example, a person can have more than one phone number, email_address, etc. Here, the
attributes “Mob_no” and “Email_id” are multi valued attributes as they can take more than
one values for a given entity.
6. Null attribute
 Whenever entity doesn’t have any applicable value for an attribute, then the attribute

By Amruta Navale
is given a NULL value. A NULL value is used when an entity does not have value for
an attribute.
 For Example: In case of Telephone_No attribute for an Employee. If employee
doesn’t have Telephone connection then the value of Telephone_No attribute is set to
NULL.
ENTITY SETS
 Entities is the basic object of E.R model.
 An entity is an object in the real world which has its own properties and it is

By Amruta Navale
distinguishable from other objects.
 An entities set is a set of entities of the same type that share the same
properties or attributes.
 For example :-

 1. The set of all persons who are students at the college and defined as a
entities set employee.
 2. If a bank has number of branches then

 branch is also a entity set. So in each branch entity-set may be described by


the attribute
 Brach_name branch_city and assets.
 For example -
 employee of a college [employee]

By Amruta Navale
 student of a college [student]
 A person entity may be an employee entity or student entity or both or sometimes no one
(from this set).
 An entity may be physically like a flower or a book or abstract like a concept or holiday.
TYPES OF ENTITIES
1. Strong Entity: An entity set that has sufficient attributes to form a primary key is called strong
entity.
 Strong entity represented by rectangle.
 e.g. Roll No is a primary key of Student

By Amruta Navale
 For example:- In a bank, customer has account. Therefore, customer and account are related
with each other.
 Customer does some transactions in a bank on the account.
 In transaction entity if transaction_no is considered as primary key, for one customer deposited
and withdrawal is done and key value starts from one because it is typically in a sequential
number.

Fig: Account Keeps log of Transaction


By Amruta Navale
2.Weak Entity: An entity set may not have sufficient attributes to form a primary key.
Such an entity set is termed a weak entity.
 An entity that depends on another entity to form a primary key is called a weak entity.
 The weak entity doesn’t contain any key attribute of its own.
 In Loan payment relationship Payment is weak entity.
 The weak entity is represented by a double rectangle.
 Even though transaction are distinct same transaction number is used for deposit and
withdrawal for different customer..
This transaction_no is not a unique value. So it is referred to as weak-entity.

By Amruta Navale

 Therefore the relationship is also weak. This is shown in the following Fig.
 For each customer the transaction_no starts at 1. See the following table.
COMPARISON BETWEEN STRONG ENTITY SET AND WEAK
ENTITY SET
Sr. No. Key Strong Entity Weak Entity
Key Strong entity always have one Weak entity have a foreign key

By Amruta Navale
1 primary key. referencing primary key of strong
entity.
Dependency Strong entity is independent of other Weak entity is dependent on strong
2
entities. entity.
Represented by A strong entity is represented by A weak entity is represented by
3
single rectangle. double rectangle.
Relationship Relationship between two strong Relationship between a strong and
4 Representation entities is represented by single weak entity is represented by
diamond. double diamond.
Participation Strong entity may or may not Weak entity always participates in
5
participate in entity relationships. entity relationships.
RELATIONSHIP, RELATIONSHIP SETS

 Relationship
 The association among entities is called a relationship. For example, an

By Amruta Navale
employee works_at a department, a student enrolls in a course. Here, Works_at and
Enrolls are called relationships.
 ‘Enrolled in’ is a relationship that exists between entities Student and Course.
 Relationship Set
 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.
 A relationship set is a set of relationships of same type. A relationship set may be a
unary relationship set or binary relationship set or ternary relationship set or n-
ary relationship set.
 A relationship set is the set of all relationship instances that participates in any relationship, so
as to define a relationship between various participating entity types.

By Amruta Navale
 For example, 2 entity types employee and department are related Via a relationship type ' works
for'.
 Relationship Type:
 Relationship Type can be defined the association between two entities.
 In a school database, a student enroll a course. Here enroll is a relationship.
 Relationship Set :
 Relationship Set can be defined a set of similar type relationship. It is represented by a diamond
and connecting the entities by line.
 In a school database, There is a relationship between student set and course set.
By Amruta Navale
CONTINUE..
TYPES OF RELATIONSHIP SET
1. Unary Relationship Set:
 Unary relationship set is a relationship set where only one entity set participates in a relationship set.

By Amruta Navale
2.Binary Relationship Set:
• Binary relationship set is a relationship set where two entity sets participate in a relationship set.
CONTINUE..
 Ternary relationship set: Ternary relationship set is a relationship set where three entity sets participate in a
relationship set.

By Amruta Navale
• N-ary relationship set: N-ary relationship set is a relationship set where ‘n’ entity sets participate in a
relationship set.
CONTINUE..
 Recursive Relationship Set:
 When an Entity is related with itself it is known as Recursive Relationship.

By Amruta Navale
UNARY, BINARY AND TERNARY
RELATIONSHIP

By Amruta Navale
DEGREE OF RELATIONSHIP
 The degree of a relationship is the number of entity types that participate(associate) in a relationship. By
seeing an E-R diagram, we can simply tell the degree of a relationship i.e the number of an entity type
that is connected to a relationship is the degree of that relationship.

By Amruta Navale
 For example, If we have two entity type ‘Customer’ and ‘Account’ and they are linked using the
primary key and foreign key. We can say that the degree of relationship is 2 because here two entities
are taking part in the relationship.
CONTINUE..
 Unary (degree 1)
 A unary relationship exists when both the participating entity type are the same. When such a
relationship is present we say that the degree of relationship is 1.

By Amruta Navale
 For example, Suppose in a classroom, we have many students who belong to a particular club-like
dance club, basketball club etc. and some of them are club leads. So, a particular group of student is
managed by their respective club lead. Here, the group is formed from students and also, the club leads
are chosen from students. So, the ‘Student’ is the only entity participating here. We can represent this
relationship using the E-R diagram as follows:
CONTINUE..
 Binary (degree 2)
 A binary relationship exists when exactly two entity type participates. When such a relationship is
present we say that the degree is 2. This is the most common degree of relationship. It is easy to deal

By Amruta Navale
with such relationship as these can be easily converted into relational tables.
 For example, We have two entity type ‘Customer’ and ‘Account’ where each ‘Customer’ has an
‘Account’ which stores the account details of the ‘Customer’. Since we have two entity types
participating we call it a binary relationship. Also, one ‘Customer’ can have many ‘Account’ but each
‘Account’ should belong to only one ‘Customer’. We can say that it is a one-to-many binary
relationship.
CONTINUE..
 Ternary(degree 3)
 A ternary relationship exists when exactly three entity type participates. When such a relationship is present
we say that the degree is 3. As the number of entity increases in the relationship, it becomes complex to
convert them into relational tables.

By Amruta Navale
 For example, We have three entity type ‘Employee’, ‘Department’ and ‘Location’. The relationship between
these entities are defined as an employee works in a department, an employee works at a particular location.
So, we can see we have three entities participating in a relationship so it is a ternary relationship. The degree
of this relation is 3.
CONTINUE..
 N-ary (n degree)
 An N-ary relationship exists when ‘n’ number of entities are participating. So, any number of entities can
participate in a relationship. There is no limitation to the maximum number of entities that can participate. But,
relations with a higher degree are not common. This is because the conversion of higher degree relations to

By Amruta Navale
relational tables gets complex. We are making an E-R model because it can be easily be converted into any
other model for implementing the database. But, this benefit is not available if we use higher degree relations.
So, binary relations are more popular and widely used.

In the above example, E1 denotes the first entity type, E2


denotes the second entity type and so on. R represents the
relationship. So, here we have a total of 5 entity type which
participates in the relationship. Therefore, the degree of the
above n-ary relationship is 5.
MAPPING CARDINALITIES

By Amruta Navale
 Mapping Cardinalities or cardinality ratios express the number of entities to which another entity
can be associated via a relationship set. For binary relationship mapping cardinality must be one of
the following.
 A relationship is represented by diamond shape in ER diagram, it shows the relationship among
entities.
 There are four types of relationships:
1. One to One
2. One to Many
3. Many to One
4. Many to Many
1. ONE TO ONE RELATIONSHIP

By Amruta Navale
 When a single instance of an entity is associated with a single instance of
another entity then it is called one to one relationship.
 For example, a person has only one passport and a passport is given to
one person.
2. ONE TO MANY RELATIONSHIP

By Amruta Navale
 When a single instance of an entity is associated with more than one instances of another
entity then it is called one to many relationship.
 For example – a customer can place many orders but a order cannot be placed by many
customers.
3. MANY TO ONE RELATIONSHIP

By Amruta Navale
 When more than one instances of an entity is associated with a single instance of another
entity then it is called many to one relationship.
 For example – many students can study in a single college but a student cannot study in
many colleges at the same time.
4. MANY TO MANY RELATIONSHIP

By Amruta Navale
 When more than one instances of an entity is associated with more than one instances of
another entity then it is called many to many relationship.
 For example, a can be assigned to many projects and a project can be assigned to many
students.
CONTINUE..
 One to One – A single row of first table associates with single row of second table. For
example, a relationship between person and passport table is one to one because a person can
have only one passport and a passport can be assigned to only one person.

By Amruta Navale
 One to Many – A single row of first table associates with more than one rows of second table.
For example, relationship between customer and order table is one to many because a customer
can place many orders but a order can be placed by a single customer alone.
 Many to One – Many rows of first table associate with a single row of second table. For
example, relationship between student and university is many to one because a university can
have many students but a student can only study only in single university at a time.
 Many to Many – Many rows of first table associate with many rows of second table. For
example, relationship between student and course table is many to many because a student can
take many courses at a time and a course can be assigned to many students.
CONTINUE..
 One to One relationship - One entity is related to almost one entity of other. Example - Student
has Rollno .
 One to Many relationship - One entity is related to many entity in one to many . Example -

By Amruta Navale
Indian Citizen has Mobile no.
 Many to One relationship - Many entity is related to one entity . for Example - Student studies
subject .
 Many to Many relationship -Many entity are related to many entity . Example - Teacher has
Student .
 Any association between two entity types is called a relationship. Entities take part in the
relationship. It is represented by a diamond shape.
 For example, A teacher teaches students. Here, "teaches" is a relationship and this is the
relationship between a Teacher entity and a Student entity.
By Amruta Navale
CONTINUE..
EXTENDED FEATURE OF ER-DIAGRAM

By Amruta Navale
 The basic E-R concept can model most of database features.
 But same aspect of database can be exp extended features.
 There are 3 extended features:
1. Specialization.
2. Generalization
3. Aggregation.
SPECIALIZATION
 In specialization, an entity is divided into sub-entities based on their characteristics. It is a top-down
approach where higher level entity is specialized into two or more lower level entities. For Example,
EMPLOYEE entity in an Employee management system can be specialized into DEVELOPER, TESTER

By Amruta Navale
etc. as shown in Figure 2. In this case, common attributes like E_NAME, E_SAL etc. become part of
higher entity (EMPLOYEE) and specialized attributes like TES_TYPE become part of specialized entity
(TESTER).
Person

Employee Student
GENERALIZATION

 It is abstracting process of viewing set of objects as a single general class.


 It concentrates on the general characteristics of consequent set while

By Amruta Navale
ignoring there differences.
 It means generalization is the result of taking union of two or more entity sets
to produce a higher level entity set.
 This line implies that a doctor has to be either a permanent doctor, or
consulting doctor nothing else.
 Therefore the entities are limited in generalization.
CONTINUE..
 The fundamental difference between generalization and specialization is that Generalization is a
bottom-up approach. However, specialization is a top-down approach.
 Generalization club all the entities that share some common properties to form a new entity. On
the other hands, specialization spilt an entity to form multiple new entities that inherit some

By Amruta Navale
properties of the split entity.
 In generalization, a higher entity must have some lower entities whereas, in specialization, a
higher entity may not have any lower entity present.
 Generalization helps in reducing the size of schema whereas, specialization is just opposite it
increases the number of entities thereby increasing the size of a schema.
 Generalization is always applied to the group of entities whereas, specialization is always
applied on a single entity.
 Generalization results in a formation of a single entity whereas, Specialization results in the
formation of multiple new entities.
By Amruta Navale
By Amruta Navale
3. AGGREGATION

🞆 It is the process of combining information on objects so that the higher level

By Amruta Navale
objects can be abstracted.
🞆 In any entity relationship diagram, we cannot form a relationship among the
entities and their relationship.
🞆 Aggregation is the process which allows to do so.
AGGREGATION
 An ER diagram is not capable of representing relationship between an entity and a relationship which may
be required in some scenarios. In those cases, a relationship with its corresponding entities is aggregated
into a higher level entity. For Example, Employee working for a project may require some machinery. So,
REQUIRE relationship is needed between relationship WORKS_FOR and entity MACHINERY. Using

By Amruta Navale
aggregation, WORKS_FOR relationship with its entities EMPLOYEE and PROJECT is aggregated into
single entity and relationship REQUIRE is created between aggregated entity and MACHINERY.
By Amruta Navale
CASE STUDIES

🞆 1. Let's consider "General Hospital" where the operations are as follows:


🞆 (a) In the hospital, many doctors are working. Their personal information is

By Amruta Navale
maintained because they get fixed salary per month.
🞆 (b) The patients are admitted to the hospital into the room. They are treated by
various doctors.
🞆 (c) Sometimes, patients require certain pathological tests which are actually
carried out into the labs.
By Amruta Navale
🞆 Star is an agency for flat booking & it has number of builders and agents who
are jointly working.A customer can get a flat for residential or commercial

By Amruta Navale
purpose.
🞆 If a customer is apporoched through an agent the agency and builders are
giving some commision to agent.Agent shows various sites and flats within
various location.Study the case and draw ER Diagram
By Amruta Navale
🞆 In a nursery plants are sold to the customers.These plants are flowering and
non flowering only.Nutrients are given to the plant with some

By Amruta Navale
quqntity.Nutrients contains Pestisides,Watering and Manure.
By Amruta Navale
🞆 A Movie studio wishes to institute a database to manage their files of movies
actor and directors.the following facts are relevant.

By Amruta Navale
🞆 Each actor has appeared in many movies.
🞆 Each director has directed many movies.
🞆 Each movie has one director or ona or more actors.
🞆 Each actor and directory may have several addresses.
By Amruta Navale
🞆 Construct an ER for car insurance company that has set of customers.
🞆 Each customer owns one or more cars.

By Amruta Navale
🞆 Each are associated with more cars.
🞆 Each can be associated with zeo to any number of recorded accidents.
By Amruta Navale
🞆 In airport airline reservation is done.Airoplanes are owned by airline which
have flight system.Passenger visits employee

By Amruta Navale
and ask for reservation.Employee checks flight
system and provide reservation to the passenger.
Draw ER Diagram.
By Amruta Navale
 The management of Life Hospital has decided to computerize their operations.
 The following information is provided by management. These are resident, fulltime and
consulting doctors, with various specialization.

By Amruta Navale
 Consulting doctors visit hospital at a fixed time everyday or some days of week which varies
from doctor to doctor .
 Patients are admitted to hospital and their main cause of admission is recorded. For accident
cases additional information such as police booklet number, name of police and accident
description is recorded. A patient is admitted to a room which has certain category having
fixed change per day.
 The given case study is of Life Hospital which has decided to computerize their operations
By Amruta Navale
🞆 Consider a trucking company which is responsible for picking up shipments
for warehouse of a retail chain and deliver the shipments to the individual

By Amruta Navale
store loaction.
🞆 A truck may carry several shipments in a single trip and deliver it to multiple
stores. Draw an ER diagram for above case.
By Amruta Navale
By Amruta Navale
Thank You!

You might also like