SlideShare a Scribd company logo
1 of 41
Entity-Relationship Modelling
Data Models
• Relational model (Data Stored in Tabular form)
• Learned Previously in Introduction to SQL
• Entity-Relationship model (mainly for
conceptual database design)
• Todays Objective
• Object-based data models (Object-oriented and
Object-relational)
• Semistructured data model (XML)
• Other older models:
• Network model
• Hierarchical model
Entity Relationship Modelling
Database Design
• After learned to
create and use a
database we’ll now
take a look at how to
design one
• Need to consider
• What tables, keys,
and constraints are
needed?
• What is the database
going to be used for?
• Conceptual design
• Build a model
independent of the
choice of DBMS
• Logical design
• Create the database
in a given DBMS
• Physical design
• How the database is
stored in hardware
Entity Relationship Modelling
Entity-Relationship (E-R)
Modelling
• E-R Modelling is used
for conceptual design
• Entities - objects or
items of interest
• Attributes - facts about,
or properties of, an
entity
• Relationships - links
between entities
• Example
• In a University
database we might
have entities for
Students, Courses and
Lecturers. Students
might have attributes
such as their ID, Name,
and DeptID, and could
have relationships with
Courses (enrol-in) and
Lecturers (teach)
Entity Relationship Modelling
Entity-Relationship E-R)
Diagrams
• E-R Models are often
represented as E-R
diagrams that
• Give a conceptual
view of the database
• Are independent of
the choice of DBMS
• Can support to
identify some
problems in a design
Entity Relationship Modelling
Student
Lecturer
Courses
Teach
Enrol-in
ID
CourseName
Entities
• Entities represent
objects or things of
interest
• Physical things like
students, lecturers,
employees, products
• More abstract things
like programs, orders,
courses, projects
• Entities have
• A general type or
class, such as
Lecturer or Program
• Instances of that
particular type, such
as Mati-ur-Rehman,
Nadeem Iqbal are
instances of Lecturer
• Attributes (such as
name, email address)
Entity Relationship Modelling
Diagramming Entities
• In an E-R Diagram, an
entity is usually drawn
as a rectangle
(simple / rounded
corner)
• The rectangle is
labelled with the name
of the class /entity
Entity Relationship Modelling
Student
Lecturer
Courses
Teach
Enrol-in
ID
CourseName
Attributes
• Attributes are facts,
aspects, properties,
or details about an
entity
• Students have IDs,
names, courses,
addresses, …
• Courses have codes,
titles, credit weights,
…
• Attributes have
• A name
• An associated entity
Entity Relationship Modelling
Diagramming Attributes
• In an E-R Diagram
attributes may be
drawn as ovals
• Each attribute is
linked to its entity by
a line
• The name of the
attribute is written in
the oval
Entity Relationship Modelling
Student
Lecturer
Courses
Teach
Enrol-in
ID
CourseName
Relationships
• Relationships are an
association between
two or more entities
• Each Student takes
several Courses
• Each Course is taught
by a Lecturer
• Each Employee works
for a single
Department
• Relationships have
• A name
• A set of entities that
participate in them
• A degree - the
number of entities
that participate (most
have degree 2)
• A cardinality ratio
• Relationship can
have descriptive
attributes
Entity Relationship Modelling
Degree of Relationship
• The number of entities that participate in relationship
• Degree of relationship
• Binary – links two entities
• Ternary – links three entities
• N-ary – links n entities
Cardinality Ratios
• Each entity in a
relationship can
participate in zero,
one, or more than
one instances of that
relationship
• This leads to 3 types
of relationship…
• One to one (1:1)
• Each lecturer has a
unique office
• One to many (1:M)
• One Department have
many faculty members
• Many to many (M:M)
• Each student takes
several courses, and
each courses is taken by
several students
Entity Relationship Modelling
Diagramming Relationships
• Relationships are
links between two
entities
• The name is given in
a diamond box
• The ends of the link
show cardinality
Entity Relationship Modelling
Student
Lecturer
Courses
Teach
Enrol-in
ID
CourseName
ManyOne
Making E-R Models
• To make an E-R
model you need to
identify
• Enitities
• Attributes
• Relationships
• Cardinality
• from a description
• General guidelines
• Since entities are
things or objects they
are often nouns in the
description
• Attributes are facts or
properties, and so are
often nouns also
• Verbs often describe
relationships between
entities
Entity Relationship Modelling
Example
A university consists of a number of departments.
Each department employs various lecturers and
offers several programs. A number of courses make
up each program. Students register in a particular
program and enrol in courses towards the
completion of that program. Each course is taken by
a lecturer from the appropriate department, and
each lecturer teaches various group of students
Entity Relationship Modelling
Example - Entities
A university consists of a number of departments.
Each department employs various lecturers and
offers several programs. A number of courses
make up each program. Students register in a
particular program and enrol in courses towards the
completion of that program. Each course is taken by
a lecturer from the appropriate department, and
each lecturer teaches various group of students
Entity Relationship Modelling
Example - Relationship
A university consists of a number of departments.
Each department employs various lecturers and
offers several programs. A number of courses
make up each program. Students register in a
particular program and enrol in courses towards
the completion of that program. Each course is
taken by a lecturer from the appropriate
department, and each lecturer teaches various
group of students
Entity Relationship Modelling
Example – (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
Lecturer
Entities: Department, Programs, Course, Lecturer, Student
Example – (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
Lecturer
Offers
Each department offers several programs
Example – (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
LecturerIncludes
Offers
A number of courses make up each program
Example - (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
LecturerIncludes
Offers
Regs In
Students register in a particular program
Example - (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
LecturerIncludes
Offers
Regs In
Enrols in
Students … enrol in courses
Example - (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
LecturerIncludes
Offers
Regs In
Enrols In
Taken by
Each course is taken by a lecturer
Example - (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
LecturerIncludes
Offers
Regs In
Enrols In
Employs
Taken by
Each department employs several Lecturers
Example - (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
LecturerIncludes
Offers
TeachesRegs In
Enrols In
Employs
Taken by
each lecturer teaches various group of students
Example - (E-R Diagram)
Entity Relationship Modelling
CoursesPrograms
Department
Student
LecturerIncludes
Offers
TeachesRegs In
Enrols In
Employs
Taken by
Entities and Attributes
• Sometimes it is hard
to tell if something
should be an entity
or an attribute
• They both represent
objects or facts about
the world
• They are both often
represented by nouns
in descriptions
• General guidelines
• Entities can have
attributes but
attributes have no
smaller parts
• Entities can have
relationships between
them, but an attribute
belongs to a single
entity
Entity Relationship Modelling
Example
We want to represent information about
products in a database. Each product
has a description, a price and a
supplier. Suppliers have addresses,
phone numbers, and names. Each
address is made up of a street address,
a city, and a postcode.
Entity Relationship Modelling
Example - Entities/Attributes
• Entities or attributes:
• product
• description
• price
• supplier
• address
• phone number
• name
• street address
• city
• postcode
• Products, suppliers,
and addresses all
have smaller parts
so we can make
them entities
• The others have no
smaller parts and
belong to a single
entity
Entity Relationship Modelling
Example - (E-R Diagram)
Entity Relationship Modelling
Product
Supplier Address
Street address
City
Postcode
Name
Phone number
Price
Description
Example - Relationships
• Each product has a
supplier
• Each product has a
single supplier but
there is nothing to
stop a supplier
supplying many
products
• A many to one
relationship
• Each supplier has an
address
• A supplier has a single
address
• It does not seem
sensible for two
different suppliers to
have the same
address
• A one to one
relationship
Entity Relationship Modelling
Example - (E-R Diagram)
Entity Relationship Modelling
Product
Supplier Address
Street address
City
Postcode
Name
Phone number
Price
Description
Has A
Has A
One to One Relationships
• Some relationships
between entities, A and
B, might be redundant
if
• It might be a 1:1
relationship between A
and B
• Every A is related to a B
and every B is related to
an A
• And B can’t exists
without a reference of A
• Example - the supplier-
address relationship
• Is one to one
• Every supplier has an
address
• We don’t need addresses
that are not related to a
supplier
• Or we can say that
address can’t exists
without a supplier
reference
Entity Relationship Modelling
Redundant Relationships
• We can merge the
two entities that take
part in a redundant
relationship together
• They become a single
entity
• The new entity has all
the attributes of the
old one
Entity Relationship Modelling
A B
a
c z
yb
x
AB
z
y
xa
c
b
Example - (E-R Diagram)
Entity Relationship Modelling
Product
Supplier
Street address
City
Postcode
Name
Phone number
Price
Description
Has A
Making E-R Diagrams
• From a description of
the requirements
identify the
• Entities
• Attributes
• Relationships
• Degree & Cardinality
of the relationships
• Draw the E-R
diagram and then
• Look at one to one
relationships as they
might be redundant
• Look at many to
many relationships as
they might need to be
split into two one to
many links
Entity Relationship Modelling
Debugging Designs
• With a bit of practice
E-R diagrams can be
used to plan queries
• You can look at the
diagram and figure
out how to find useful
information
• If you can’t find the
information you need,
you may need to
change the design
Entity Relationship Modelling
How can you
find a list of
students who
are enrolled
in Database
systems?
Courses
Student
Enrols In
Debugging Designs
Entity Relationship Modelling
ID
Code
Code
Title
ID
Name
Courses
Student
Enrols In
• Enrols in relates the
student with courses
• As discuss earlier that
a relationship can
have attributes
• Why?
• Mostly to make the
real relationship
amongst entities that
have many to many
relationship.
• Relationship can have
its own descriptive
attributes.
Debugging Designs
Entity Relationship Modelling
ID
Code
Code
Title
ID
Name
Courses
Student
Enrols In
• Relationship can have its
own descriptive attributes
• A student have some
specific grade in some
specific course
• So grade is an attribute
• Is the grade belongs to
Student?
Debugging Designs
Entity Relationship Modelling
ID
Code
Code
Title
ID
Name
Courses
Student
Enrols In
• Relationship can have its
own descriptive attributes
• A student have some
specific grade in some
specific course
• So grade is an attribute
• Is the grade belongs to
Student?
• No. The grade is such an
attribute which can’t exists
without the relationship
amongst both student and
course.
• So it will be the part of Enrol
In
Grade
Question
Entity Relationship Modelling
• The below mentioned attributes will belongs to?
• CGPA
• GPA

More Related Content

What's hot

What's hot (20)

Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 
Unit i b(er model)
Unit i b(er model)Unit i b(er model)
Unit i b(er model)
 
Data base lec3 (erd)
Data base lec3 (erd)Data base lec3 (erd)
Data base lec3 (erd)
 
Entity relationship diagram (erd)
Entity relationship  diagram (erd)Entity relationship  diagram (erd)
Entity relationship diagram (erd)
 
Er diagram
Er diagramEr diagram
Er diagram
 
10287 lecture5(2)
10287 lecture5(2)10287 lecture5(2)
10287 lecture5(2)
 
Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Entity relationship modelling - DE L300
Entity relationship modelling - DE L300
 
Entity relationship modelling
Entity relationship modellingEntity relationship modelling
Entity relationship modelling
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Entity Relationship Diagram2
Entity Relationship Diagram2Entity Relationship Diagram2
Entity Relationship Diagram2
 
Data modeling
Data modelingData modeling
Data modeling
 
E-R diagram in Database
E-R diagram in DatabaseE-R diagram in Database
E-R diagram in Database
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Erd1
Erd1Erd1
Erd1
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Data model and entity relationship
Data model and entity relationshipData model and entity relationship
Data model and entity relationship
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 

Similar to ER_model

Similar to ER_model (20)

Database Design and Entity relationship Model.pptx
Database Design and Entity relationship Model.pptxDatabase Design and Entity relationship Model.pptx
Database Design and Entity relationship Model.pptx
 
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptxDATA MODEL PRESENTATION UNIT I-BCA I.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
 
ER-Diagram.pptx
ER-Diagram.pptxER-Diagram.pptx
ER-Diagram.pptx
 
RDBMS ER (Entity Relationship) Diagram.pptx
RDBMS ER (Entity Relationship) Diagram.pptxRDBMS ER (Entity Relationship) Diagram.pptx
RDBMS ER (Entity Relationship) Diagram.pptx
 
Day 1 SQL.pptx
Day 1 SQL.pptxDay 1 SQL.pptx
Day 1 SQL.pptx
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Ube Databases
Ube DatabasesUbe Databases
Ube Databases
 
er-models.pptx
er-models.pptxer-models.pptx
er-models.pptx
 
Cn presentation on the topic called as re modelling
Cn presentation on the topic called as re modellingCn presentation on the topic called as re modelling
Cn presentation on the topic called as re modelling
 
3-db-er_3-db-er_3-db-er_3-db-er_3-db-er.pptx
3-db-er_3-db-er_3-db-er_3-db-er_3-db-er.pptx3-db-er_3-db-er_3-db-er_3-db-er_3-db-er.pptx
3-db-er_3-db-er_3-db-er_3-db-er_3-db-er.pptx
 
ERModel1.pdf
ERModel1.pdfERModel1.pdf
ERModel1.pdf
 
Data model
Data modelData model
Data model
 
19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf19IS305_U1_LP3_LM3-22-23-2.pdf
19IS305_U1_LP3_LM3-22-23-2.pdf
 
E_R-Diagram (2).pptx
E_R-Diagram (2).pptxE_R-Diagram (2).pptx
E_R-Diagram (2).pptx
 
Unit iv dbms
Unit   iv dbmsUnit   iv dbms
Unit iv dbms
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
DATA MODELS.pptx
DATA MODELS.pptxDATA MODELS.pptx
DATA MODELS.pptx
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 

Recently uploaded

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Recently uploaded (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

ER_model

  • 2. Data Models • Relational model (Data Stored in Tabular form) • Learned Previously in Introduction to SQL • Entity-Relationship model (mainly for conceptual database design) • Todays Objective • Object-based data models (Object-oriented and Object-relational) • Semistructured data model (XML) • Other older models: • Network model • Hierarchical model Entity Relationship Modelling
  • 3. Database Design • After learned to create and use a database we’ll now take a look at how to design one • Need to consider • What tables, keys, and constraints are needed? • What is the database going to be used for? • Conceptual design • Build a model independent of the choice of DBMS • Logical design • Create the database in a given DBMS • Physical design • How the database is stored in hardware Entity Relationship Modelling
  • 4. Entity-Relationship (E-R) Modelling • E-R Modelling is used for conceptual design • Entities - objects or items of interest • Attributes - facts about, or properties of, an entity • Relationships - links between entities • Example • In a University database we might have entities for Students, Courses and Lecturers. Students might have attributes such as their ID, Name, and DeptID, and could have relationships with Courses (enrol-in) and Lecturers (teach) Entity Relationship Modelling
  • 5. Entity-Relationship E-R) Diagrams • E-R Models are often represented as E-R diagrams that • Give a conceptual view of the database • Are independent of the choice of DBMS • Can support to identify some problems in a design Entity Relationship Modelling Student Lecturer Courses Teach Enrol-in ID CourseName
  • 6. Entities • Entities represent objects or things of interest • Physical things like students, lecturers, employees, products • More abstract things like programs, orders, courses, projects • Entities have • A general type or class, such as Lecturer or Program • Instances of that particular type, such as Mati-ur-Rehman, Nadeem Iqbal are instances of Lecturer • Attributes (such as name, email address) Entity Relationship Modelling
  • 7. Diagramming Entities • In an E-R Diagram, an entity is usually drawn as a rectangle (simple / rounded corner) • The rectangle is labelled with the name of the class /entity Entity Relationship Modelling Student Lecturer Courses Teach Enrol-in ID CourseName
  • 8. Attributes • Attributes are facts, aspects, properties, or details about an entity • Students have IDs, names, courses, addresses, … • Courses have codes, titles, credit weights, … • Attributes have • A name • An associated entity Entity Relationship Modelling
  • 9. Diagramming Attributes • In an E-R Diagram attributes may be drawn as ovals • Each attribute is linked to its entity by a line • The name of the attribute is written in the oval Entity Relationship Modelling Student Lecturer Courses Teach Enrol-in ID CourseName
  • 10. Relationships • Relationships are an association between two or more entities • Each Student takes several Courses • Each Course is taught by a Lecturer • Each Employee works for a single Department • Relationships have • A name • A set of entities that participate in them • A degree - the number of entities that participate (most have degree 2) • A cardinality ratio • Relationship can have descriptive attributes Entity Relationship Modelling
  • 11. Degree of Relationship • The number of entities that participate in relationship • Degree of relationship • Binary – links two entities • Ternary – links three entities • N-ary – links n entities
  • 12. Cardinality Ratios • Each entity in a relationship can participate in zero, one, or more than one instances of that relationship • This leads to 3 types of relationship… • One to one (1:1) • Each lecturer has a unique office • One to many (1:M) • One Department have many faculty members • Many to many (M:M) • Each student takes several courses, and each courses is taken by several students Entity Relationship Modelling
  • 13. Diagramming Relationships • Relationships are links between two entities • The name is given in a diamond box • The ends of the link show cardinality Entity Relationship Modelling Student Lecturer Courses Teach Enrol-in ID CourseName ManyOne
  • 14. Making E-R Models • To make an E-R model you need to identify • Enitities • Attributes • Relationships • Cardinality • from a description • General guidelines • Since entities are things or objects they are often nouns in the description • Attributes are facts or properties, and so are often nouns also • Verbs often describe relationships between entities Entity Relationship Modelling
  • 15. Example A university consists of a number of departments. Each department employs various lecturers and offers several programs. A number of courses make up each program. Students register in a particular program and enrol in courses towards the completion of that program. Each course is taken by a lecturer from the appropriate department, and each lecturer teaches various group of students Entity Relationship Modelling
  • 16. Example - Entities A university consists of a number of departments. Each department employs various lecturers and offers several programs. A number of courses make up each program. Students register in a particular program and enrol in courses towards the completion of that program. Each course is taken by a lecturer from the appropriate department, and each lecturer teaches various group of students Entity Relationship Modelling
  • 17. Example - Relationship A university consists of a number of departments. Each department employs various lecturers and offers several programs. A number of courses make up each program. Students register in a particular program and enrol in courses towards the completion of that program. Each course is taken by a lecturer from the appropriate department, and each lecturer teaches various group of students Entity Relationship Modelling
  • 18. Example – (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student Lecturer Entities: Department, Programs, Course, Lecturer, Student
  • 19. Example – (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student Lecturer Offers Each department offers several programs
  • 20. Example – (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student LecturerIncludes Offers A number of courses make up each program
  • 21. Example - (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student LecturerIncludes Offers Regs In Students register in a particular program
  • 22. Example - (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student LecturerIncludes Offers Regs In Enrols in Students … enrol in courses
  • 23. Example - (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student LecturerIncludes Offers Regs In Enrols In Taken by Each course is taken by a lecturer
  • 24. Example - (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student LecturerIncludes Offers Regs In Enrols In Employs Taken by Each department employs several Lecturers
  • 25. Example - (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student LecturerIncludes Offers TeachesRegs In Enrols In Employs Taken by each lecturer teaches various group of students
  • 26. Example - (E-R Diagram) Entity Relationship Modelling CoursesPrograms Department Student LecturerIncludes Offers TeachesRegs In Enrols In Employs Taken by
  • 27. Entities and Attributes • Sometimes it is hard to tell if something should be an entity or an attribute • They both represent objects or facts about the world • They are both often represented by nouns in descriptions • General guidelines • Entities can have attributes but attributes have no smaller parts • Entities can have relationships between them, but an attribute belongs to a single entity Entity Relationship Modelling
  • 28. Example We want to represent information about products in a database. Each product has a description, a price and a supplier. Suppliers have addresses, phone numbers, and names. Each address is made up of a street address, a city, and a postcode. Entity Relationship Modelling
  • 29. Example - Entities/Attributes • Entities or attributes: • product • description • price • supplier • address • phone number • name • street address • city • postcode • Products, suppliers, and addresses all have smaller parts so we can make them entities • The others have no smaller parts and belong to a single entity Entity Relationship Modelling
  • 30. Example - (E-R Diagram) Entity Relationship Modelling Product Supplier Address Street address City Postcode Name Phone number Price Description
  • 31. Example - Relationships • Each product has a supplier • Each product has a single supplier but there is nothing to stop a supplier supplying many products • A many to one relationship • Each supplier has an address • A supplier has a single address • It does not seem sensible for two different suppliers to have the same address • A one to one relationship Entity Relationship Modelling
  • 32. Example - (E-R Diagram) Entity Relationship Modelling Product Supplier Address Street address City Postcode Name Phone number Price Description Has A Has A
  • 33. One to One Relationships • Some relationships between entities, A and B, might be redundant if • It might be a 1:1 relationship between A and B • Every A is related to a B and every B is related to an A • And B can’t exists without a reference of A • Example - the supplier- address relationship • Is one to one • Every supplier has an address • We don’t need addresses that are not related to a supplier • Or we can say that address can’t exists without a supplier reference Entity Relationship Modelling
  • 34. Redundant Relationships • We can merge the two entities that take part in a redundant relationship together • They become a single entity • The new entity has all the attributes of the old one Entity Relationship Modelling A B a c z yb x AB z y xa c b
  • 35. Example - (E-R Diagram) Entity Relationship Modelling Product Supplier Street address City Postcode Name Phone number Price Description Has A
  • 36. Making E-R Diagrams • From a description of the requirements identify the • Entities • Attributes • Relationships • Degree & Cardinality of the relationships • Draw the E-R diagram and then • Look at one to one relationships as they might be redundant • Look at many to many relationships as they might need to be split into two one to many links Entity Relationship Modelling
  • 37. Debugging Designs • With a bit of practice E-R diagrams can be used to plan queries • You can look at the diagram and figure out how to find useful information • If you can’t find the information you need, you may need to change the design Entity Relationship Modelling How can you find a list of students who are enrolled in Database systems? Courses Student Enrols In
  • 38. Debugging Designs Entity Relationship Modelling ID Code Code Title ID Name Courses Student Enrols In • Enrols in relates the student with courses • As discuss earlier that a relationship can have attributes • Why? • Mostly to make the real relationship amongst entities that have many to many relationship. • Relationship can have its own descriptive attributes.
  • 39. Debugging Designs Entity Relationship Modelling ID Code Code Title ID Name Courses Student Enrols In • Relationship can have its own descriptive attributes • A student have some specific grade in some specific course • So grade is an attribute • Is the grade belongs to Student?
  • 40. Debugging Designs Entity Relationship Modelling ID Code Code Title ID Name Courses Student Enrols In • Relationship can have its own descriptive attributes • A student have some specific grade in some specific course • So grade is an attribute • Is the grade belongs to Student? • No. The grade is such an attribute which can’t exists without the relationship amongst both student and course. • So it will be the part of Enrol In Grade
  • 41. Question Entity Relationship Modelling • The below mentioned attributes will belongs to? • CGPA • GPA