SlideShare a Scribd company logo
1 of 45
ENTITYENTITY
RELATIONSHIPRELATIONSHIP
DIAGRAMDIAGRAM
An entity relationship diagram is a graphicalAn entity relationship diagram is a graphical
representation of an organisation's datarepresentation of an organisation's data
storage requirementsstorage requirements
E-R-D are used to:E-R-D are used to:
Identify the data that must be captured,Identify the data that must be captured,
stored and retrieved in order to supportstored and retrieved in order to support
the businessthe business
Activities performed by an organisationActivities performed by an organisation
Identify the data required to derive andIdentify the data required to derive and
report on the performance measures, thatreport on the performance measures, that
an organisation should be monitoringan organisation should be monitoring
Entity relationship diagrams have threeEntity relationship diagrams have three
different components:different components:
ENTITIESENTITIES
ATTRIBUTESATTRIBUTES
RELATIONSHIPSRELATIONSHIPS
Entities are the people, places, things,Entities are the people, places, things,
events and concepts of interest to anevents and concepts of interest to an
organisation.organisation.
Represented as RectangleRepresented as Rectangle
• BookBook
• ProjectProject
• PublisherPublisher
• JobJob
• CompanyCompany
• FileFile
EntityEntity
AttributeAttribute
Properties or characteristics possessed byProperties or characteristics possessed by
an entity are called as attributesan entity are called as attributes
Represented as ellipse.Represented as ellipse.
Attributes of EMPLOYEE entity set :Attributes of EMPLOYEE entity set :
NameName
AgeAge
Employee_idEmployee_id
SalarySalary
DomainDomain
The set of possible values for an attribute isThe set of possible values for an attribute is
called the domain of the attribute.called the domain of the attribute.
The domain of attribute marital status isThe domain of attribute marital status is
just the four values: single, married,just the four values: single, married,
divorced, widowed.divorced, widowed.
The domain of the attribute month is theThe domain of the attribute month is the
twelve values ranging from January totwelve values ranging from January to
December.December.
Simple v/s Composite attributeSimple v/s Composite attribute
Simple attributeSimple attribute: An attribute that cannot: An attribute that cannot
be divided into simpler componentsbe divided into simpler components
e.g. age of an employee, pub-id of a book,e.g. age of an employee, pub-id of a book,
title of a book.title of a book.
Composite attributeComposite attribute: An attribute that: An attribute that
can be split into components e.g. Date ofcan be split into components e.g. Date of
joining of the employee can be split intojoining of the employee can be split into
day, month and yearday, month and year
Single v/s Multi-valued AttributeSingle v/s Multi-valued Attribute
Single valuedSingle valued : Attributes that can take on: Attributes that can take on
only a single value for each entity instance.only a single value for each entity instance.
e.g. age of employee, pubid of a publishere.g. age of employee, pubid of a publisher
Multi-valuedMulti-valued: Attributes that can take: Attributes that can take
many values for each entity instance.many values for each entity instance.
e.g. skill set of employeee.g. skill set of employee
Stored v/s Derived attributeStored v/s Derived attribute
Stored Attribute:Stored Attribute: Attribute that need to beAttribute that need to be
stored permanently.stored permanently.
e.g. : Name of an employeee.g. : Name of an employee
Derived AttributeDerived Attribute: Attribute that can be: Attribute that can be
calculated based on other attributes.calculated based on other attributes.
e.g. : Years of service of employee can bee.g. : Years of service of employee can be
calculated from date of joining and currentcalculated from date of joining and current
datedate
AttributesAttributes
K e y A t t r i b u t e M u l t i V a l u e d
A t t r i b u t e
E m p l o y e e S k i l l sE #
N a m e A g e
D O B A d d r e s s
F l o o r
S t r e e t
B u i l d i n g
D e r i v e d
A t t r i b u t e
C o m p o s i t e
A t t r i b u t e
RelationshipRelationship
Defines the set of all associations betweenDefines the set of all associations between
two entity types.two entity types.
Represented as RhombusRepresented as Rhombus
Example:Example:
EMPLOYEEs work in a DEPARTMENTEMPLOYEEs work in a DEPARTMENT
LAWYERs advise CLIENTsLAWYERs advise CLIENTs
EQUIPMENT is allocated to PROJECTsEQUIPMENT is allocated to PROJECTs
TRUCK is a type of VEHICLETRUCK is a type of VEHICLE
Degree of a RelationshipDegree of a Relationship
The number of entities associated with theThe number of entities associated with the
relationship.relationship.
One – UnaryOne – Unary
employee - manager-of - employeeemployee - manager-of - employee
Two – BinaryTwo – Binary
employee - works-for – departmentemployee - works-for – department
Three – TernaryThree – Ternary
customer – purchase- itemcustomer – purchase- item
Unary RelationshipUnary Relationship
E m p lo y e e M a n a g e s
Binary RelationshipBinary Relationship
E m p lo y e e D e p a r tm e n tW o r k s fo r
Ternary RelationshipTernary Relationship
P r e s c r i p t i o nD o c t o r P a t i e n t
M e d i c i n e
Cardinality and ConnectivityCardinality and Connectivity
The cardinality of a relationship is theThe cardinality of a relationship is the
actual number of related occurrences foractual number of related occurrences for
each of the two entitieseach of the two entities
–– one-to-one (1:1)one-to-one (1:1)
–– one-to-many (1:N)one-to-many (1:N)
–– many-to- one (M:1)many-to- one (M:1)
–– many-to-many (M:N)many-to-many (M:N)
one-to-one (1:1)one-to-one (1:1)
when at most one instance of a entity A iswhen at most one instance of a entity A is
associated with one instance of entity Bassociated with one instance of entity B
E 1
E 2
E 3
E 4
C 1
C 2
C 3
C 4
E M P L O Y E E C H A I R
one-to-many (1:N)one-to-many (1:N)
when for one instance of entity A, there are zero, one, orwhen for one instance of entity A, there are zero, one, or
many instances of entity B, but for one instance of entitymany instances of entity B, but for one instance of entity
B, there is only one instance of entity AB, there is only one instance of entity A
O 1
O 2
O 3
E 1
E 2
E 3
E 4
E 5
O R G A N I Z A T I O N E M P L O Y E E
many-to- One (M:1)many-to- One (M:1)
When for zero, one or many instances of entity A, thereWhen for zero, one or many instances of entity A, there
is only one instance of entity B , but for one instance ofis only one instance of entity B , but for one instance of
entity B, there is only one instance of entity Aentity B, there is only one instance of entity A
D 1
D 2
D 3
E 1
E 2
E 3
E 4
E 5
D E P A R T M E N TE M P L O Y E E
many-to-many (M:N)many-to-many (M:N)
when for one instance of entity A, there are zero, one, orwhen for one instance of entity A, there are zero, one, or
many instances of entity B and for one instance of entitymany instances of entity B and for one instance of entity
B there are zero, one, or many instances of entity AB there are zero, one, or many instances of entity A
P 1
P 2
P 3
P 4
E 1
E 2
E 3
E 4
P R O J E C TE M P O L Y E E
CardinalityCardinality
We express cardinality constraints byWe express cardinality constraints by
drawing either a directed line (drawing either a directed line (→→),),
signifying “one,” or an undirected line (—),signifying “one,” or an undirected line (—),
signifying “many,” between thesignifying “many,” between the
relationship set and the entity set.relationship set and the entity set.
One-to-One RelationshipOne-to-One Relationship
– A customer is associated with at most oneA customer is associated with at most one
loan via the relationshiploan via the relationship borrowerborrower
– A loan is associated with at most oneA loan is associated with at most one
customer viacustomer via borrowerborrower
One-To-Many RelationshipOne-To-Many Relationship
In the one-to-many relationship a loan isIn the one-to-many relationship a loan is
associated with at most one customer viaassociated with at most one customer via
borrowerborrower, a customer is associated with, a customer is associated with
several loans viaseveral loans via borrowerborrower
Many-To-One RelationshipsMany-To-One Relationships
In a many-to-one relationship a loan isIn a many-to-one relationship a loan is
associated with several customers viaassociated with several customers via
borrowerborrower, a customer is associated with at, a customer is associated with at
most one loan viamost one loan via borrowerborrower
Many-To-Many RelationshipMany-To-Many Relationship
A customer is associated with severalA customer is associated with several
loans via borrowerloans via borrower
A loan is associated with severalA loan is associated with several
customers via borrowercustomers via borrower
Participation of an Entity Set inParticipation of an Entity Set in
a Relationship Seta Relationship Set
TotalTotal participationparticipation (indicated by double line): every entity in the entity set(indicated by double line): every entity in the entity set
participates in at least one relationship in the relationship setparticipates in at least one relationship in the relationship set
E.g. participation ofE.g. participation of loanloan inin borrowerborrower is totalis total
every loan must have a customer associated to it via borrowerevery loan must have a customer associated to it via borrower
Partial participationPartial participation: some entities may not participate in any relationship in: some entities may not participate in any relationship in
the relationship setthe relationship set
E.g. participation ofE.g. participation of customercustomer inin borrowerborrower is partialis partial
Case Study – ER Model For aCase Study – ER Model For a
college DBcollege DB
Assumptions :Assumptions :
A college contains many departmentsA college contains many departments
Each department can offer any number of coursesEach department can offer any number of courses
Many instructors can work in a departmentMany instructors can work in a department
An instructor can work only in one departmentAn instructor can work only in one department
For each department there is a HeadFor each department there is a Head
An instructor can be head of only one departmentAn instructor can be head of only one department
Each instructor can take any number of coursesEach instructor can take any number of courses
A course can be taken by only one instructorA course can be taken by only one instructor
A student can enroll for any number of coursesA student can enroll for any number of courses
Each course can have any number of studentsEach course can have any number of students
Steps in ER ModelingSteps in ER Modeling
Step 1: Identify the EntitiesStep 1: Identify the Entities
Step 2: Find the relationshipsStep 2: Find the relationships
Step 3: Identify the key attributesStep 3: Identify the key attributes
Step 4: Identify other relevant attributesStep 4: Identify other relevant attributes
Step 5: Draw complete E-R diagramStep 5: Draw complete E-R diagram
with all attributes including Primarywith all attributes including Primary
KeyKey
Case StudyCase Study
Banking Business ScenarioBanking Business Scenario
Assumptions :Assumptions :
There are multiple banks and each bankThere are multiple banks and each bank
has many branches. Each branch hashas many branches. Each branch has
multiple customersmultiple customers
Customers have various types of accountsCustomers have various types of accounts
Some Customers also had taken differentSome Customers also had taken different
types of loans from these bank branchestypes of loans from these bank branches
One customer can have multiple accountsOne customer can have multiple accounts
and Loansand Loans
Step 1: Identify the EntitiesStep 1: Identify the Entities
DEPARTMENTDEPARTMENT
STUDENTSTUDENT
COURSECOURSE
INSTRUCTORINSTRUCTOR
Step 2: Find the relationshipsStep 2: Find the relationships
One course is enrolled by multiple students and one student enrollsOne course is enrolled by multiple students and one student enrolls
for multiple courses, hence the cardinality between course andfor multiple courses, hence the cardinality between course and
student is Many to Many.student is Many to Many.
M NM N
The department offers many courses and each course belongs toThe department offers many courses and each course belongs to
only one department, hence the cardinality between department andonly one department, hence the cardinality between department and
course is One to Many.course is One to Many.
1 M1 M
One department has multiple instructors and one instructor belongsOne department has multiple instructors and one instructor belongs
to one and only one department , hence the cardinality betweento one and only one department , hence the cardinality between
department and instructor is one to Many.department and instructor is one to Many.
STUDENTCOURSE ENROLLED BY
DEPARTMENT COURSE
OFFERS
DEPARTMENT INSTRUCTOR
HAS
3232
Step 2: Find the relationships(Cont..)Step 2: Find the relationships(Cont..)
Each department there is a “Head of department” and one instructorEach department there is a “Head of department” and one instructor
is “Head of department “,hence the cardinality is one to one .is “Head of department “,hence the cardinality is one to one .
1 11 1
One course is taught by only one instructor, but the instructorOne course is taught by only one instructor, but the instructor
teaches many courses, hence the cardinality between course andteaches many courses, hence the cardinality between course and
instructor is many to one.instructor is many to one.
M 1M 1
DEPARTMENT INSTRUCTORHEADED BY
COURSE INSTRUCTOR
OFFERS
3333
Deptname is the key attribute for the Entity “Department”,Deptname is the key attribute for the Entity “Department”,
as it identifies the Department uniquely.as it identifies the Department uniquely.
Course# (CourseId) is the key attribute for “Course” Entity.Course# (CourseId) is the key attribute for “Course” Entity.
Student# (Student Number) is the key attribute forStudent# (Student Number) is the key attribute for
“Student” Entity.“Student” Entity.
Instructor Name is the key attribute for “Instructor” Entity.Instructor Name is the key attribute for “Instructor” Entity.
Step 4: Identify other relevant attributesStep 4: Identify other relevant attributes
For the department entity, the relevant attribute is locationFor the department entity, the relevant attribute is location
For course entity, course name, duration,prerequisiteFor course entity, course name, duration,prerequisite
For instructor entity, room#, telephone#For instructor entity, room#, telephone#
For student entity, student name, date of birthFor student entity, student name, date of birth
Step 3: Identify the key attributes
Draw ERDDraw ERD
ER Diagram for the UniversityER Diagram for the University
Reduction of an E-R SchemaReduction of an E-R Schema
to Tablesto Tables
Converting relationshipsConverting relationships
Unary 1:1 – The primary key fieldUnary 1:1 – The primary key field
itself will become the foreign key initself will become the foreign key in
the tablethe table
Converting relationshipsConverting relationships
Binary 1: 1: The primary keyBinary 1: 1: The primary key
of either of the entities canof either of the entities can
become a foreign key in thebecome a foreign key in the
other.other.
Converting relationshipsConverting relationships
Binary 1: N: The primary key of theBinary 1: N: The primary key of the
“1” side of the relationship“1” side of the relationship
becomes a foreign key in thebecomes a foreign key in the
relation on the “N” siderelation on the “N” side
Converting relationshipsConverting relationships
Binary M: N-Binary M: N-
A new table is created to representA new table is created to represent
relationshiprelationship
Contains two foreign keys – one fromContains two foreign keys – one from
each of participating entitieseach of participating entities
The primary key of new table is theThe primary key of new table is the
combination of two foreign keyscombination of two foreign keys
Converting relationshipsConverting relationships
Converting relationshipsConverting relationships
Ternary relationship:Ternary relationship:
A new table is created to representA new table is created to represent
relationshiprelationship
The new table contains three foreign keys-The new table contains three foreign keys-
one from each of the participating entitiesone from each of the participating entities
The primary key of new table is theThe primary key of new table is the
combination of all three foreign keyscombination of all three foreign keys
THANK YOUTHANK YOU

More Related Content

What's hot

D I T211 Chapter 3
D I T211    Chapter 3D I T211    Chapter 3
D I T211 Chapter 3
askme
 
E-R diagram in Database
E-R diagram in DatabaseE-R diagram in Database
E-R diagram in Database
Fatiha Qureshi
 
Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Entity relationship modelling - DE L300
Entity relationship modelling - DE L300
Edwin Ayernor
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
Nikhil Deswal
 

What's hot (19)

Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
ERD - Entity Relationship Diagram
ERD - Entity Relationship DiagramERD - Entity Relationship Diagram
ERD - Entity Relationship Diagram
 
Presentation database about ERD
Presentation database about ERDPresentation database about ERD
Presentation database about ERD
 
The entity relationship model
The entity relationship modelThe entity relationship model
The entity relationship model
 
Desigining of Database - ER Model
Desigining of Database - ER ModelDesigining of Database - ER Model
Desigining of Database - ER Model
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship Modelling
 
D I T211 Chapter 3
D I T211    Chapter 3D I T211    Chapter 3
D I T211 Chapter 3
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
Entity relationship diagram for dummies
Entity relationship diagram for dummiesEntity relationship diagram for dummies
Entity relationship diagram for dummies
 
Entity Relationship Diagram2
Entity Relationship Diagram2Entity Relationship Diagram2
Entity Relationship Diagram2
 
Erd examples
Erd examplesErd examples
Erd examples
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
Data modeling
Data modelingData modeling
Data modeling
 
Unit02 dbms
Unit02 dbmsUnit02 dbms
Unit02 dbms
 
E-R diagram in Database
E-R diagram in DatabaseE-R diagram in Database
E-R diagram in Database
 
Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Entity relationship modelling - DE L300
Entity relationship modelling - DE L300
 
E r model
E r modelE r model
E r model
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
03 Ch3 Notes Revised
03 Ch3 Notes Revised03 Ch3 Notes Revised
03 Ch3 Notes Revised
 

Similar to Dbms ppt

Er Model Nandha&Mani
Er Model Nandha&ManiEr Model Nandha&Mani
Er Model Nandha&Mani
guest1e0229a
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
koolkampus
 
Pertemuan-4------------------------------------------------
Pertemuan-4------------------------------------------------Pertemuan-4------------------------------------------------
Pertemuan-4------------------------------------------------
keishaangelina2
 

Similar to Dbms ppt (20)

E R Model details.ppt
E R Model details.pptE R Model details.ppt
E R Model details.ppt
 
Er Model Nandha&Mani
Er Model Nandha&ManiEr Model Nandha&Mani
Er Model Nandha&Mani
 
27 fcs157al3
27 fcs157al327 fcs157al3
27 fcs157al3
 
ER model
ER modelER model
ER model
 
Er model
Er modelEr model
Er model
 
dbms
dbmsdbms
dbms
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
Test presentation
Test presentationTest presentation
Test presentation
 
Pertemuan-4------------------------------------------------
Pertemuan-4------------------------------------------------Pertemuan-4------------------------------------------------
Pertemuan-4------------------------------------------------
 
Conceptual Modeling of Data
Conceptual Modeling of DataConceptual Modeling of Data
Conceptual Modeling of Data
 
DBMS Unit-2_Final.pptx
DBMS Unit-2_Final.pptxDBMS Unit-2_Final.pptx
DBMS Unit-2_Final.pptx
 
ER Model and other topics in DBMS
ER Model and other topics in DBMSER Model and other topics in DBMS
ER Model and other topics in DBMS
 
database.pptx
database.pptxdatabase.pptx
database.pptx
 
Chapter 2. Concepctual design -.pptx
Chapter 2. Concepctual design -.pptxChapter 2. Concepctual design -.pptx
Chapter 2. Concepctual design -.pptx
 
dbms er model
dbms er modeldbms er model
dbms er model
 
Basic concepts of Data and Databases
Basic concepts of Data and Databases Basic concepts of Data and Databases
Basic concepts of Data and Databases
 
abuukarE r model
abuukarE r modelabuukarE r model
abuukarE r model
 
Data & Databases
Data & Databases Data & Databases
Data & Databases
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 

Dbms ppt

  • 2. An entity relationship diagram is a graphicalAn entity relationship diagram is a graphical representation of an organisation's datarepresentation of an organisation's data storage requirementsstorage requirements E-R-D are used to:E-R-D are used to: Identify the data that must be captured,Identify the data that must be captured, stored and retrieved in order to supportstored and retrieved in order to support the businessthe business Activities performed by an organisationActivities performed by an organisation Identify the data required to derive andIdentify the data required to derive and report on the performance measures, thatreport on the performance measures, that an organisation should be monitoringan organisation should be monitoring
  • 3. Entity relationship diagrams have threeEntity relationship diagrams have three different components:different components: ENTITIESENTITIES ATTRIBUTESATTRIBUTES RELATIONSHIPSRELATIONSHIPS
  • 4. Entities are the people, places, things,Entities are the people, places, things, events and concepts of interest to anevents and concepts of interest to an organisation.organisation. Represented as RectangleRepresented as Rectangle • BookBook • ProjectProject • PublisherPublisher • JobJob • CompanyCompany • FileFile EntityEntity
  • 5. AttributeAttribute Properties or characteristics possessed byProperties or characteristics possessed by an entity are called as attributesan entity are called as attributes Represented as ellipse.Represented as ellipse. Attributes of EMPLOYEE entity set :Attributes of EMPLOYEE entity set : NameName AgeAge Employee_idEmployee_id SalarySalary
  • 6. DomainDomain The set of possible values for an attribute isThe set of possible values for an attribute is called the domain of the attribute.called the domain of the attribute. The domain of attribute marital status isThe domain of attribute marital status is just the four values: single, married,just the four values: single, married, divorced, widowed.divorced, widowed. The domain of the attribute month is theThe domain of the attribute month is the twelve values ranging from January totwelve values ranging from January to December.December.
  • 7. Simple v/s Composite attributeSimple v/s Composite attribute Simple attributeSimple attribute: An attribute that cannot: An attribute that cannot be divided into simpler componentsbe divided into simpler components e.g. age of an employee, pub-id of a book,e.g. age of an employee, pub-id of a book, title of a book.title of a book. Composite attributeComposite attribute: An attribute that: An attribute that can be split into components e.g. Date ofcan be split into components e.g. Date of joining of the employee can be split intojoining of the employee can be split into day, month and yearday, month and year
  • 8. Single v/s Multi-valued AttributeSingle v/s Multi-valued Attribute Single valuedSingle valued : Attributes that can take on: Attributes that can take on only a single value for each entity instance.only a single value for each entity instance. e.g. age of employee, pubid of a publishere.g. age of employee, pubid of a publisher Multi-valuedMulti-valued: Attributes that can take: Attributes that can take many values for each entity instance.many values for each entity instance. e.g. skill set of employeee.g. skill set of employee
  • 9. Stored v/s Derived attributeStored v/s Derived attribute Stored Attribute:Stored Attribute: Attribute that need to beAttribute that need to be stored permanently.stored permanently. e.g. : Name of an employeee.g. : Name of an employee Derived AttributeDerived Attribute: Attribute that can be: Attribute that can be calculated based on other attributes.calculated based on other attributes. e.g. : Years of service of employee can bee.g. : Years of service of employee can be calculated from date of joining and currentcalculated from date of joining and current datedate
  • 10. AttributesAttributes K e y A t t r i b u t e M u l t i V a l u e d A t t r i b u t e E m p l o y e e S k i l l sE # N a m e A g e D O B A d d r e s s F l o o r S t r e e t B u i l d i n g D e r i v e d A t t r i b u t e C o m p o s i t e A t t r i b u t e
  • 11. RelationshipRelationship Defines the set of all associations betweenDefines the set of all associations between two entity types.two entity types. Represented as RhombusRepresented as Rhombus Example:Example: EMPLOYEEs work in a DEPARTMENTEMPLOYEEs work in a DEPARTMENT LAWYERs advise CLIENTsLAWYERs advise CLIENTs EQUIPMENT is allocated to PROJECTsEQUIPMENT is allocated to PROJECTs TRUCK is a type of VEHICLETRUCK is a type of VEHICLE
  • 12. Degree of a RelationshipDegree of a Relationship The number of entities associated with theThe number of entities associated with the relationship.relationship. One – UnaryOne – Unary employee - manager-of - employeeemployee - manager-of - employee Two – BinaryTwo – Binary employee - works-for – departmentemployee - works-for – department Three – TernaryThree – Ternary customer – purchase- itemcustomer – purchase- item
  • 13. Unary RelationshipUnary Relationship E m p lo y e e M a n a g e s
  • 14. Binary RelationshipBinary Relationship E m p lo y e e D e p a r tm e n tW o r k s fo r
  • 15. Ternary RelationshipTernary Relationship P r e s c r i p t i o nD o c t o r P a t i e n t M e d i c i n e
  • 16. Cardinality and ConnectivityCardinality and Connectivity The cardinality of a relationship is theThe cardinality of a relationship is the actual number of related occurrences foractual number of related occurrences for each of the two entitieseach of the two entities –– one-to-one (1:1)one-to-one (1:1) –– one-to-many (1:N)one-to-many (1:N) –– many-to- one (M:1)many-to- one (M:1) –– many-to-many (M:N)many-to-many (M:N)
  • 17. one-to-one (1:1)one-to-one (1:1) when at most one instance of a entity A iswhen at most one instance of a entity A is associated with one instance of entity Bassociated with one instance of entity B E 1 E 2 E 3 E 4 C 1 C 2 C 3 C 4 E M P L O Y E E C H A I R
  • 18. one-to-many (1:N)one-to-many (1:N) when for one instance of entity A, there are zero, one, orwhen for one instance of entity A, there are zero, one, or many instances of entity B, but for one instance of entitymany instances of entity B, but for one instance of entity B, there is only one instance of entity AB, there is only one instance of entity A O 1 O 2 O 3 E 1 E 2 E 3 E 4 E 5 O R G A N I Z A T I O N E M P L O Y E E
  • 19. many-to- One (M:1)many-to- One (M:1) When for zero, one or many instances of entity A, thereWhen for zero, one or many instances of entity A, there is only one instance of entity B , but for one instance ofis only one instance of entity B , but for one instance of entity B, there is only one instance of entity Aentity B, there is only one instance of entity A D 1 D 2 D 3 E 1 E 2 E 3 E 4 E 5 D E P A R T M E N TE M P L O Y E E
  • 20. many-to-many (M:N)many-to-many (M:N) when for one instance of entity A, there are zero, one, orwhen for one instance of entity A, there are zero, one, or many instances of entity B and for one instance of entitymany instances of entity B and for one instance of entity B there are zero, one, or many instances of entity AB there are zero, one, or many instances of entity A P 1 P 2 P 3 P 4 E 1 E 2 E 3 E 4 P R O J E C TE M P O L Y E E
  • 21. CardinalityCardinality We express cardinality constraints byWe express cardinality constraints by drawing either a directed line (drawing either a directed line (→→),), signifying “one,” or an undirected line (—),signifying “one,” or an undirected line (—), signifying “many,” between thesignifying “many,” between the relationship set and the entity set.relationship set and the entity set.
  • 22. One-to-One RelationshipOne-to-One Relationship – A customer is associated with at most oneA customer is associated with at most one loan via the relationshiploan via the relationship borrowerborrower – A loan is associated with at most oneA loan is associated with at most one customer viacustomer via borrowerborrower
  • 23. One-To-Many RelationshipOne-To-Many Relationship In the one-to-many relationship a loan isIn the one-to-many relationship a loan is associated with at most one customer viaassociated with at most one customer via borrowerborrower, a customer is associated with, a customer is associated with several loans viaseveral loans via borrowerborrower
  • 24. Many-To-One RelationshipsMany-To-One Relationships In a many-to-one relationship a loan isIn a many-to-one relationship a loan is associated with several customers viaassociated with several customers via borrowerborrower, a customer is associated with at, a customer is associated with at most one loan viamost one loan via borrowerborrower
  • 25. Many-To-Many RelationshipMany-To-Many Relationship A customer is associated with severalA customer is associated with several loans via borrowerloans via borrower A loan is associated with severalA loan is associated with several customers via borrowercustomers via borrower
  • 26. Participation of an Entity Set inParticipation of an Entity Set in a Relationship Seta Relationship Set TotalTotal participationparticipation (indicated by double line): every entity in the entity set(indicated by double line): every entity in the entity set participates in at least one relationship in the relationship setparticipates in at least one relationship in the relationship set E.g. participation ofE.g. participation of loanloan inin borrowerborrower is totalis total every loan must have a customer associated to it via borrowerevery loan must have a customer associated to it via borrower Partial participationPartial participation: some entities may not participate in any relationship in: some entities may not participate in any relationship in the relationship setthe relationship set E.g. participation ofE.g. participation of customercustomer inin borrowerborrower is partialis partial
  • 27. Case Study – ER Model For aCase Study – ER Model For a college DBcollege DB Assumptions :Assumptions : A college contains many departmentsA college contains many departments Each department can offer any number of coursesEach department can offer any number of courses Many instructors can work in a departmentMany instructors can work in a department An instructor can work only in one departmentAn instructor can work only in one department For each department there is a HeadFor each department there is a Head An instructor can be head of only one departmentAn instructor can be head of only one department Each instructor can take any number of coursesEach instructor can take any number of courses A course can be taken by only one instructorA course can be taken by only one instructor A student can enroll for any number of coursesA student can enroll for any number of courses Each course can have any number of studentsEach course can have any number of students
  • 28. Steps in ER ModelingSteps in ER Modeling Step 1: Identify the EntitiesStep 1: Identify the Entities Step 2: Find the relationshipsStep 2: Find the relationships Step 3: Identify the key attributesStep 3: Identify the key attributes Step 4: Identify other relevant attributesStep 4: Identify other relevant attributes Step 5: Draw complete E-R diagramStep 5: Draw complete E-R diagram with all attributes including Primarywith all attributes including Primary KeyKey
  • 29. Case StudyCase Study Banking Business ScenarioBanking Business Scenario Assumptions :Assumptions : There are multiple banks and each bankThere are multiple banks and each bank has many branches. Each branch hashas many branches. Each branch has multiple customersmultiple customers Customers have various types of accountsCustomers have various types of accounts Some Customers also had taken differentSome Customers also had taken different types of loans from these bank branchestypes of loans from these bank branches One customer can have multiple accountsOne customer can have multiple accounts and Loansand Loans
  • 30. Step 1: Identify the EntitiesStep 1: Identify the Entities DEPARTMENTDEPARTMENT STUDENTSTUDENT COURSECOURSE INSTRUCTORINSTRUCTOR
  • 31. Step 2: Find the relationshipsStep 2: Find the relationships One course is enrolled by multiple students and one student enrollsOne course is enrolled by multiple students and one student enrolls for multiple courses, hence the cardinality between course andfor multiple courses, hence the cardinality between course and student is Many to Many.student is Many to Many. M NM N The department offers many courses and each course belongs toThe department offers many courses and each course belongs to only one department, hence the cardinality between department andonly one department, hence the cardinality between department and course is One to Many.course is One to Many. 1 M1 M One department has multiple instructors and one instructor belongsOne department has multiple instructors and one instructor belongs to one and only one department , hence the cardinality betweento one and only one department , hence the cardinality between department and instructor is one to Many.department and instructor is one to Many. STUDENTCOURSE ENROLLED BY DEPARTMENT COURSE OFFERS DEPARTMENT INSTRUCTOR HAS
  • 32. 3232 Step 2: Find the relationships(Cont..)Step 2: Find the relationships(Cont..) Each department there is a “Head of department” and one instructorEach department there is a “Head of department” and one instructor is “Head of department “,hence the cardinality is one to one .is “Head of department “,hence the cardinality is one to one . 1 11 1 One course is taught by only one instructor, but the instructorOne course is taught by only one instructor, but the instructor teaches many courses, hence the cardinality between course andteaches many courses, hence the cardinality between course and instructor is many to one.instructor is many to one. M 1M 1 DEPARTMENT INSTRUCTORHEADED BY COURSE INSTRUCTOR OFFERS
  • 33. 3333 Deptname is the key attribute for the Entity “Department”,Deptname is the key attribute for the Entity “Department”, as it identifies the Department uniquely.as it identifies the Department uniquely. Course# (CourseId) is the key attribute for “Course” Entity.Course# (CourseId) is the key attribute for “Course” Entity. Student# (Student Number) is the key attribute forStudent# (Student Number) is the key attribute for “Student” Entity.“Student” Entity. Instructor Name is the key attribute for “Instructor” Entity.Instructor Name is the key attribute for “Instructor” Entity. Step 4: Identify other relevant attributesStep 4: Identify other relevant attributes For the department entity, the relevant attribute is locationFor the department entity, the relevant attribute is location For course entity, course name, duration,prerequisiteFor course entity, course name, duration,prerequisite For instructor entity, room#, telephone#For instructor entity, room#, telephone# For student entity, student name, date of birthFor student entity, student name, date of birth Step 3: Identify the key attributes
  • 34. Draw ERDDraw ERD ER Diagram for the UniversityER Diagram for the University
  • 35. Reduction of an E-R SchemaReduction of an E-R Schema to Tablesto Tables Converting relationshipsConverting relationships Unary 1:1 – The primary key fieldUnary 1:1 – The primary key field itself will become the foreign key initself will become the foreign key in the tablethe table
  • 36.
  • 37. Converting relationshipsConverting relationships Binary 1: 1: The primary keyBinary 1: 1: The primary key of either of the entities canof either of the entities can become a foreign key in thebecome a foreign key in the other.other.
  • 38.
  • 39. Converting relationshipsConverting relationships Binary 1: N: The primary key of theBinary 1: N: The primary key of the “1” side of the relationship“1” side of the relationship becomes a foreign key in thebecomes a foreign key in the relation on the “N” siderelation on the “N” side
  • 40.
  • 41. Converting relationshipsConverting relationships Binary M: N-Binary M: N- A new table is created to representA new table is created to represent relationshiprelationship Contains two foreign keys – one fromContains two foreign keys – one from each of participating entitieseach of participating entities The primary key of new table is theThe primary key of new table is the combination of two foreign keyscombination of two foreign keys
  • 43. Converting relationshipsConverting relationships Ternary relationship:Ternary relationship: A new table is created to representA new table is created to represent relationshiprelationship The new table contains three foreign keys-The new table contains three foreign keys- one from each of the participating entitiesone from each of the participating entities The primary key of new table is theThe primary key of new table is the combination of all three foreign keyscombination of all three foreign keys
  • 44.