SlideShare a Scribd company logo
Database
Management System
[COMP 232, Credit: 3, September 2024]
Sanjog Sigdel,
Lecturer, DoCSE
Kathmandu University
Course Contents
1. Introduction: Database Systems Applications, Database System versus File systems,
View of Data, Database Languages, Database Users and Administrators, Transaction
Management, Database Architecture. [3 Hrs]
2. Database Design: Design Process, Entity Relationship Model, Constraints, Keys,
Entity-Relationship Diagram, Design Issues, Weak Entity Sets, Extended E-R
features, Design of an E-R Database Schema, Reduction of an E-R Schema to tables.
[6 Hrs.]
Database Management System | COMP 232 | September 2024 2
Sanjog Sigdel, September 2024
Recap of past lecture
- Mapping Cardinality Constraint
- Primary Key
- Weak Entity Sets
Database Management System | COMP 232 | September 2024 3
Sanjog Sigdel, September 2024
● one-to-many relationship between an instructor and a student
○ an instructor is associated with several (including 0) students via
advisor
○ a student is associated with at most one instructor via advisor,
One-to-Many Relationship
Database Management System | COMP 232 | September 2024 4
Sanjog Sigdel, September 2024
● In a many-to-one relationship between an instructor and a student,
○ an instructor is associated with at most one student via advisor,
○ and a student is associated with several (including 0) instructors via
advisor
Many-to-One Relationship
Database Management System | COMP 232 | September 2024 5
Sanjog Sigdel, September 2024
● An instructor is associated with several (possibly 0) students via advisor
● A student is associated with several (possibly 0) instructors via advisor
Many-to-Many Relationship
Database Management System | COMP 232 | September 2024 6
Sanjog Sigdel, September 2024
● Total participation (indicated by double line): every entity in the entity set
participates in at least one relationship in the relationship set
participation of student in advisor relation is total
○ every student must have an associated instructor
● Partial participation: some entities may not participate in any relationship in
the relationship set
○ Example: participation of instructor in advisor is partial
Total and Partial Participation
Database Management System | COMP 232 | September 2024 7
Sanjog Sigdel, September 2024
ER Diagram Example
Database Management System | COMP 232 | September 2024 8
Sanjog Sigdel, September 2024
Department
Offers
Courses
teaches
enrollm
ent
advisor
Professor
Courses
major
faculty
9
Design choices:
1. Should a concept be modeled as an entity or an attribute?
2. Should a concept be modeled as an entity or a relationship?
3. Identifying relationships: Binary or ternary? Aggregation?
Constraints in the ER Model:
4. A lot of data semantics can (and should) be captured.
5. But some constraints cannot be captured in ER diagrams.
Design Issues
Database Management System | COMP 232 | September 2024 10
Sanjog Sigdel, September 2024
Use of entity sets vs. attributes
- Use of phone as an entity allows extra information about phone numbers.
- Should phone be an attribute of Employees or an entity (connected to
inst_phone by a relationship)?
- Depends upon the use we want to make of phone information, and the
semantics of the data:
- If we have several phone per employee, phone must be an entity (since
attributes cannot be set-valued)
Design Issues
Database Management System | COMP 232 | September 2024 11
Sanjog Sigdel, September 2024
Use of entity sets vs. relationship sets
Possible guideline is to designate a relationship set to describe an action that occurs
between entities
Design Issues
Database Management System | COMP 232 | September 2024 12
Sanjog Sigdel, September 2024
Binary versus n-ary relationship sets
Although it is possible to replace any nonbinary (n-ary, for n > 2) relationship set
by a number of distinct binary relationship sets, a n-ary relationship set shows more
clearly that several entities participate in a single relationship.
e.g., attribute date as attribute of advisor or as attribute of student
Design Issues
Database Management System | COMP 232 | September 2024 13
Sanjog Sigdel, September 2024
Example: Ternary Relationship
● Entities:
○ Student (e.g., student_id, name)
○ Course (e.g., course_id, course_name)
○ Instructor (e.g., instructor_id, name)
● Ternary Relationship:
○ Enrolled captures that a student is enrolled in a course taught by a specific instructor.
In this case, the relationship is best modeled as a ternary relationship because all three entities are
directly connected in a meaningful way that depends on all of them.
Design Issues
Database Management System | COMP 232 | September 2024 14
Sanjog Sigdel, September 2024
Benefits of an n-ary Relationship
● Clearer Representation of Participation:
● Preventing Redundancy and Ambiguity:
If we were to decompose this relationship into multiple binary
relationships, we might need to create:
1. A relationship between Student and Course.
2. A relationship between Course and Instructor.
3. Possibly, a relationship between Student and Instructor.
Design Issues
Database Management System | COMP 232 | September 2024 15
Sanjog Sigdel, September 2024
Benefits of an n-ary Relationship
● Clearer Representation of Participation
● Accurate Modeling of Real-World Constraints:
● Preventing Redundancy and Ambiguity:
If we were to decompose this relationship into multiple binary
relationships, we might need to create:
1. A relationship between Student and Course.
2. A relationship between Course and Instructor.
3. Possibly, a relationship between Student and Instructor.
Design Issues
Database Management System | COMP 232 | September 2024 16
Sanjog Sigdel, September 2024
Drawbacks of Using Binary Relationships
● Loss of Context
● Increased Complexity
Managing multiple binary relationships often requires extra joins in SQL
queries, which can lead to more complex database operations and lower query
performance. These joins are not as efficient as directly working with a
single, well-defined n-ary relationship.
Design Issues
Database Management System | COMP 232 | September 2024 17
Sanjog Sigdel, September 2024
Cardinality Constraints on Ternary Relationship
- We allow at most one arrow out of a ternary (or greater degree) relationship to
indicate a cardinality constraint
- If there is more than one arrow, there are two ways of defining the meaning.
- E.g., a ternary relationship R between A, B and C with arrows to B and C
could mean
- 1. each A entity is associated with a unique entity from B and C or
- 2. each pair of entities from (A, B) is associated with a unique C entity,
and each pair (A, C) is associated with a unique B
- Each alternative has been used in different formalisms
- To avoid confusion we outlaw more than one arrow
Design Issues
Database Management System | COMP 232 | September 2024 18
Sanjog Sigdel, September 2024
Converting Non-Binary Relationships to Binary Form
- In general, any non-binary relationship can be represented using binary
relationships by creating an artificial entity set.
- Replace R between entity sets A, B and C by an entity set E, and three
relationship sets:
1. RA, relating E and A 2. RB, relating E and B
3. RC, relating E and C
- Create a special identifying attribute for E
Design Issues
Database Management System | COMP 232 | September 2024 19
Sanjog Sigdel, September 2024
Design Issues
Database Management System | COMP 232 | September 2024
Converting Non-Binary Relationships to Binary Form
- Add any attributes of R to E
- For each relationship (ai , bi , ci) in R, create
1. a new entity ei in the entity set E 2. add (ei , ai ) to RA
3. add (ei , bi ) to RB 4. add (ei , ci ) to RC
20
Sanjog Sigdel, September 2024
Reduction to Relational Schemas
Database Management System | COMP 232 | September 2024
● Entity sets and relationship sets can be expressed uniformly as relation schemas
that represent the contents of the database.
● A database which conforms to an E-R diagram can be represented by a collection
of schemas.
● For each entity set and relationship set there is a unique schema that is assigned the
name of the corresponding entity set or relationship set.
● Each schema has a number of columns (generally corresponding to attributes),
which have unique names.
21
Sanjog Sigdel, September 2024
Reduction to Relation Schemas
Database Management System | COMP 232 | September 2024
A strong entity set reduces to a schema with the same attributes
student(ID, name, tot_cred)
A weak entity set becomes a table that includes a column for the primary key of the
identifying strong entity set
section ( course_id, sec_id, sem, year )
Example
22
Sanjog Sigdel, September 2024
Representation of Entity Sets with Multivalued Attributes
Database Management System | COMP 232 | September 2024
- A multivalued attribute M of an entity E is represented by a separate schema EM
- Schema EM has attributes corresponding to the primary key of E and an attribute
corresponding to multivalued attribute M
- Example: Multivalued attribute phone_number of instructor is represented by a
schema:
inst_phone= ( ID, phone_number)
- Each value of the multivalued attribute maps to a separate tuple of the relation on
schema EM
For example, an instructor entity with primary key 22222 and phone
numbers 456-7890 and 123-4567 maps to two tuples:
(22222, 456-7890) and (22222, 123-4567)
23
Sanjog Sigdel, September 2024

More Related Content

PPTX
COMP232 DBMS Lecture 4 - Database Design.pptx
PPT
Er model
PDF
Database Design and the ER Model, Indexing and Hashing
PPTX
Introduction to ER Diagrams
PPT
Unit 2 ER Model.ppterfgmefwlgmkldfsmglkdfg
PPTX
Entity Relationship Model
PPT
Module 1 session 5
PPTX
ER Modeling and Introduction to RDBMS
COMP232 DBMS Lecture 4 - Database Design.pptx
Er model
Database Design and the ER Model, Indexing and Hashing
Introduction to ER Diagrams
Unit 2 ER Model.ppterfgmefwlgmkldfsmglkdfg
Entity Relationship Model
Module 1 session 5
ER Modeling and Introduction to RDBMS

Similar to COMP232 DBMS Lecture 5 - Database Design (1).pptx (20)

PPT
ER Model Ppt.ppt
PPTX
entityrelationshipmodel.pptx
PPT
ermodelN in database management system.ppt
PPTX
rdbms3, dbms,dbms,rdbmssssssssssssssssssssssssssssssssss
PPT
ch7.pptbbbbbbbbgggfrredddddddddyuiklkrwwyjhghggg
PPTX
Day 1 SQL.pptx
PPTX
SQL.pptx
PPTX
Revision ch 3
PPT
entity-relationship-diagram-chen-&-crow -model.ppt
PPTX
ER-Diagram.pptx , ER diagram , entity reltaionship diagram , data base
PPT
Er diagrams
ODP
ER Model in DBMS
PPTX
database_design_presentation, data base design presenttion
PPTX
Design issues with constraints of E-R model
PDF
Unit1 rdbms study_materials-converted (1) (1)
PDF
Unit1 rdbms study_materials
PDF
L7 er2
PPTX
UNIT 1-RELATIONAL DATA MODEL for data base subject
PPTX
U2_ER_modeling.pptx
PPTX
Data Models and Relational Database Design.pptx
ER Model Ppt.ppt
entityrelationshipmodel.pptx
ermodelN in database management system.ppt
rdbms3, dbms,dbms,rdbmssssssssssssssssssssssssssssssssss
ch7.pptbbbbbbbbgggfrredddddddddyuiklkrwwyjhghggg
Day 1 SQL.pptx
SQL.pptx
Revision ch 3
entity-relationship-diagram-chen-&-crow -model.ppt
ER-Diagram.pptx , ER diagram , entity reltaionship diagram , data base
Er diagrams
ER Model in DBMS
database_design_presentation, data base design presenttion
Design issues with constraints of E-R model
Unit1 rdbms study_materials-converted (1) (1)
Unit1 rdbms study_materials
L7 er2
UNIT 1-RELATIONAL DATA MODEL for data base subject
U2_ER_modeling.pptx
Data Models and Relational Database Design.pptx
Ad

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation theory and applications.pdf
PDF
KodekX | Application Modernization Development
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Unlocking AI with Model Context Protocol (MCP)
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation theory and applications.pdf
KodekX | Application Modernization Development
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Ad

COMP232 DBMS Lecture 5 - Database Design (1).pptx

  • 1. Database Management System [COMP 232, Credit: 3, September 2024] Sanjog Sigdel, Lecturer, DoCSE Kathmandu University
  • 2. Course Contents 1. Introduction: Database Systems Applications, Database System versus File systems, View of Data, Database Languages, Database Users and Administrators, Transaction Management, Database Architecture. [3 Hrs] 2. Database Design: Design Process, Entity Relationship Model, Constraints, Keys, Entity-Relationship Diagram, Design Issues, Weak Entity Sets, Extended E-R features, Design of an E-R Database Schema, Reduction of an E-R Schema to tables. [6 Hrs.] Database Management System | COMP 232 | September 2024 2 Sanjog Sigdel, September 2024
  • 3. Recap of past lecture - Mapping Cardinality Constraint - Primary Key - Weak Entity Sets Database Management System | COMP 232 | September 2024 3 Sanjog Sigdel, September 2024
  • 4. ● one-to-many relationship between an instructor and a student ○ an instructor is associated with several (including 0) students via advisor ○ a student is associated with at most one instructor via advisor, One-to-Many Relationship Database Management System | COMP 232 | September 2024 4 Sanjog Sigdel, September 2024
  • 5. ● In a many-to-one relationship between an instructor and a student, ○ an instructor is associated with at most one student via advisor, ○ and a student is associated with several (including 0) instructors via advisor Many-to-One Relationship Database Management System | COMP 232 | September 2024 5 Sanjog Sigdel, September 2024
  • 6. ● An instructor is associated with several (possibly 0) students via advisor ● A student is associated with several (possibly 0) instructors via advisor Many-to-Many Relationship Database Management System | COMP 232 | September 2024 6 Sanjog Sigdel, September 2024
  • 7. ● Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set participation of student in advisor relation is total ○ every student must have an associated instructor ● Partial participation: some entities may not participate in any relationship in the relationship set ○ Example: participation of instructor in advisor is partial Total and Partial Participation Database Management System | COMP 232 | September 2024 7 Sanjog Sigdel, September 2024
  • 8. ER Diagram Example Database Management System | COMP 232 | September 2024 8 Sanjog Sigdel, September 2024 Department Offers Courses teaches enrollm ent advisor Professor Courses major faculty
  • 9. 9
  • 10. Design choices: 1. Should a concept be modeled as an entity or an attribute? 2. Should a concept be modeled as an entity or a relationship? 3. Identifying relationships: Binary or ternary? Aggregation? Constraints in the ER Model: 4. A lot of data semantics can (and should) be captured. 5. But some constraints cannot be captured in ER diagrams. Design Issues Database Management System | COMP 232 | September 2024 10 Sanjog Sigdel, September 2024
  • 11. Use of entity sets vs. attributes - Use of phone as an entity allows extra information about phone numbers. - Should phone be an attribute of Employees or an entity (connected to inst_phone by a relationship)? - Depends upon the use we want to make of phone information, and the semantics of the data: - If we have several phone per employee, phone must be an entity (since attributes cannot be set-valued) Design Issues Database Management System | COMP 232 | September 2024 11 Sanjog Sigdel, September 2024
  • 12. Use of entity sets vs. relationship sets Possible guideline is to designate a relationship set to describe an action that occurs between entities Design Issues Database Management System | COMP 232 | September 2024 12 Sanjog Sigdel, September 2024
  • 13. Binary versus n-ary relationship sets Although it is possible to replace any nonbinary (n-ary, for n > 2) relationship set by a number of distinct binary relationship sets, a n-ary relationship set shows more clearly that several entities participate in a single relationship. e.g., attribute date as attribute of advisor or as attribute of student Design Issues Database Management System | COMP 232 | September 2024 13 Sanjog Sigdel, September 2024
  • 14. Example: Ternary Relationship ● Entities: ○ Student (e.g., student_id, name) ○ Course (e.g., course_id, course_name) ○ Instructor (e.g., instructor_id, name) ● Ternary Relationship: ○ Enrolled captures that a student is enrolled in a course taught by a specific instructor. In this case, the relationship is best modeled as a ternary relationship because all three entities are directly connected in a meaningful way that depends on all of them. Design Issues Database Management System | COMP 232 | September 2024 14 Sanjog Sigdel, September 2024
  • 15. Benefits of an n-ary Relationship ● Clearer Representation of Participation: ● Preventing Redundancy and Ambiguity: If we were to decompose this relationship into multiple binary relationships, we might need to create: 1. A relationship between Student and Course. 2. A relationship between Course and Instructor. 3. Possibly, a relationship between Student and Instructor. Design Issues Database Management System | COMP 232 | September 2024 15 Sanjog Sigdel, September 2024
  • 16. Benefits of an n-ary Relationship ● Clearer Representation of Participation ● Accurate Modeling of Real-World Constraints: ● Preventing Redundancy and Ambiguity: If we were to decompose this relationship into multiple binary relationships, we might need to create: 1. A relationship between Student and Course. 2. A relationship between Course and Instructor. 3. Possibly, a relationship between Student and Instructor. Design Issues Database Management System | COMP 232 | September 2024 16 Sanjog Sigdel, September 2024
  • 17. Drawbacks of Using Binary Relationships ● Loss of Context ● Increased Complexity Managing multiple binary relationships often requires extra joins in SQL queries, which can lead to more complex database operations and lower query performance. These joins are not as efficient as directly working with a single, well-defined n-ary relationship. Design Issues Database Management System | COMP 232 | September 2024 17 Sanjog Sigdel, September 2024
  • 18. Cardinality Constraints on Ternary Relationship - We allow at most one arrow out of a ternary (or greater degree) relationship to indicate a cardinality constraint - If there is more than one arrow, there are two ways of defining the meaning. - E.g., a ternary relationship R between A, B and C with arrows to B and C could mean - 1. each A entity is associated with a unique entity from B and C or - 2. each pair of entities from (A, B) is associated with a unique C entity, and each pair (A, C) is associated with a unique B - Each alternative has been used in different formalisms - To avoid confusion we outlaw more than one arrow Design Issues Database Management System | COMP 232 | September 2024 18 Sanjog Sigdel, September 2024
  • 19. Converting Non-Binary Relationships to Binary Form - In general, any non-binary relationship can be represented using binary relationships by creating an artificial entity set. - Replace R between entity sets A, B and C by an entity set E, and three relationship sets: 1. RA, relating E and A 2. RB, relating E and B 3. RC, relating E and C - Create a special identifying attribute for E Design Issues Database Management System | COMP 232 | September 2024 19 Sanjog Sigdel, September 2024
  • 20. Design Issues Database Management System | COMP 232 | September 2024 Converting Non-Binary Relationships to Binary Form - Add any attributes of R to E - For each relationship (ai , bi , ci) in R, create 1. a new entity ei in the entity set E 2. add (ei , ai ) to RA 3. add (ei , bi ) to RB 4. add (ei , ci ) to RC 20 Sanjog Sigdel, September 2024
  • 21. Reduction to Relational Schemas Database Management System | COMP 232 | September 2024 ● Entity sets and relationship sets can be expressed uniformly as relation schemas that represent the contents of the database. ● A database which conforms to an E-R diagram can be represented by a collection of schemas. ● For each entity set and relationship set there is a unique schema that is assigned the name of the corresponding entity set or relationship set. ● Each schema has a number of columns (generally corresponding to attributes), which have unique names. 21 Sanjog Sigdel, September 2024
  • 22. Reduction to Relation Schemas Database Management System | COMP 232 | September 2024 A strong entity set reduces to a schema with the same attributes student(ID, name, tot_cred) A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set section ( course_id, sec_id, sem, year ) Example 22 Sanjog Sigdel, September 2024
  • 23. Representation of Entity Sets with Multivalued Attributes Database Management System | COMP 232 | September 2024 - A multivalued attribute M of an entity E is represented by a separate schema EM - Schema EM has attributes corresponding to the primary key of E and an attribute corresponding to multivalued attribute M - Example: Multivalued attribute phone_number of instructor is represented by a schema: inst_phone= ( ID, phone_number) - Each value of the multivalued attribute maps to a separate tuple of the relation on schema EM For example, an instructor entity with primary key 22222 and phone numbers 456-7890 and 123-4567 maps to two tuples: (22222, 456-7890) and (22222, 123-4567) 23 Sanjog Sigdel, September 2024