0% found this document useful (0 votes)
8 views44 pages

Module 2

Uploaded by

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

Module 2

Uploaded by

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

CSE2004: Database Management System

Module 2
Data Modeling – ER Model and
Relational Model
Topics to be Covered

 Entity-Relationship Model
 Types of Attributes
 Relationship
 Structural Constraints
 Relational Model
 Relational Model Constraints
 Mapping E-R Model to Relational Schema
 Integrity Constraints
Entity-Relationship(ER) Model

 The ER model is a high-level conceptual data model. It has not been


implemented in any commercial DBMS , but is a powerful short hand
often used in database design for a first rendition of the miniworld.
 The ER model was introduced by Peter Chen in 1976, and is now the most
widely used conceptual data model.
Definitions

 An entity is an object in the miniworld.


 An attribute is the properties of an entity which can have a value from a value set (domain)
 An entity set is the set of entities of same type that same same properties
 A relationship is an association among several entities
 A relationship set is a mathematical relation among n  2 entities, each taken from entity
sets
 A key attribute of an entity type is one whose value uniquely identifies an entity of that
type.
 A combination of attributes may form a composite key.
 If there is no applicable value for an attribute that attribute is set to a null value.
Entity Sets
instructor_ID instructor_name student-ID student_name

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


Relationship Set advisor
(student-instructor)

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


E-R Diagram - Symbols
 Rectangles represent entity sets.
 Diamonds represent relationship sets.
 Lines link attributes to entity sets and entity sets to relationship sets.
 Ellipses represent attributes
 Double ellipses represent multivalued attributes.
 Dashed ellipses denote derived attributes.
 Underline indicates primary key attributes (will study later)

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


E-R Diagram - Symbols

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Types of Attributes

 Attributes can be
 composite / simple (atomic)
 single-valued / multivalued
 stored / derived
 descriptive
 key / nonkey.
Composite Attributes

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


ER Diagram with Composite, Multi-valued and
Derived Attributes

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


ER Diagram with Descriptive Attributes (Relationship
Sets with attributes)

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Roles

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Structural Constraints
 Mapping Cardinalities
 One-to-One
 One-to-Many
 Many-to-One
 Many-to-Many
 Participation Constraints
 Total
 Partial
Mapping Cardinalities – One-to-One

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


Mapping Cardinalities – One-to-Many

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


Mapping Cardinalities – Many-to-One

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


Mapping Cardinalities – Many-to-Many

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


Notation for Expressing More Complex Constraints

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


Total Participation
 Total participation (indicated by double line): every entity in the entity set
participates in at least one relationship in the relationship set
 Example: 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

Database System Concepts, Silberschatz, Korth and Sudharsan 7 th Edition


ER Diagram with Ternary Relationship

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Weak Entity Set
 Entity with No primary key
 Weak Entity is depicted with Double
Rectangle
 Weak Relationship is depicted with
Double Diamonds
 Participation is Total for all weak
entity sets.
 Mapping Cardinality is One-to-
Many
 Weak entity depends on the
identifying entity (Strong entity) for
its unique representation.
Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition
Extended E-R Model
 Specialization – Subgrouping
 Generalization – Top-Down Design Process
 Design Constraint
 Disjoint
 Overlapping
 Completeness Constraint
 Total
 Partial
 Attribute Inheritance

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Example

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Aggregation

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Summary of Symbols

Database System Concepts, Silberschatz, Korth and Sudharsan 4 th Edition


Example

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


Relational Model
• The relational Model of Data is based on the concept of a
Relation
• Informally, a relation looks like a table of values.
• A relation typically contains a set of rows.
• The data elements in each row represent certain facts that
correspond to a real-world entity or relationship
• In the formal model, rows are called tuples
• Each column has a column header that gives an indication of the
meaning of the data items in that colum
• In the formal model, the column header is called an attribute name (or
just attribute)

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


Relational Model

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


Relational Model

Informal Terms Formal Terms


Table Relation
Column Header Attribute
All possible Column Values Domain
Row Tuple

Table Definition Schema of a Relation


Populated Table State of the Relation

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


Relational Model Constraints

 Key Constraints
 Primary Key (1 Key)
 Foreign Key (Referential Integrity)
 Candidate key (Minimal Super Key)
 Super Key (1 or more Keys)

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


Relational Model Constraints – Candidate Keys

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


Relational Schema

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


ER to Relational Mapping
 ER-to-Relational Mapping Algorithm
 Step 1: Mapping of Regular Entity Types
 Step 2: Mapping of Weak Entity Types
 Step 3: Mapping of Binary 1:1 Relation Types
 Step 4: Mapping of Binary 1:N Relationship Types.
 Step 5: Mapping of Binary M:N Relationship Types.
 Step 6: Mapping of Multivalued attributes.
 Step 7: Mapping of N-ary Relationship Types.

 Mapping EER Model Constructs to Relations


 Step 8: Options for Mapping Specialization or Generalization.
 Step 9: Mapping of Union Types (Categories).
Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition
ER to Relational Mapping

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


ER to Relational Mapping

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


EER to Relational Mapping

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


EER to Relational Mapping

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


EER to Relational Mapping

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


EER to Relational Mapping

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


EER to Relational Mapping - Exercise

Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition


Integrity Constraints
 NOT NULL Constraint: Ensures that a column cannot have NULL
value.
 DEFAULT Constraint: Provides a default value for a column when
none is specified.
 UNIQUE Constraint: Ensures that all values in a column are different.
 PRIMARY Key: Uniquely identified each rows/records in a database
table.
 FOREIGN Key: Uniquely identified a rows/records in any another
database table.
 CHECK Constraint: The CHECK constraint ensures that all values in
a column satisfy certain conditions.
References
1. Fundamentals Database Systems, Elmasri, Navathe, 7 th Edition,
Pearson Publication
2. Database System Concepts, Silberschatz, Korth and Sudharsan, 7 th
Edition
3. Database System Concepts, Silberschatz, Korth and Sudharsan, 4 th
Edition
Thank You…

You might also like