0% found this document useful (0 votes)
1 views

Module 2

The document covers the fundamentals of Data Modeling in Database Management Systems, focusing on the Entity Relationship (ER) Model, its components like entities, attributes, and relationships, and the process of mapping ER models to relational schemas. It discusses various types of attributes, cardinality, and keys, along with the importance of data modeling as a blueprint for database design. Additionally, it outlines steps for converting ER models into relational schemas and highlights common pitfalls in schema design.

Uploaded by

justice.chitra.v
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Module 2

The document covers the fundamentals of Data Modeling in Database Management Systems, focusing on the Entity Relationship (ER) Model, its components like entities, attributes, and relationships, and the process of mapping ER models to relational schemas. It discusses various types of attributes, cardinality, and keys, along with the importance of data modeling as a blueprint for database design. Additionally, it outlines steps for converting ER models into relational schemas and highlights common pitfalls in schema design.

Uploaded by

justice.chitra.v
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 54

CSE2004 – Database Management Systems

Module 2 DataModeling

Dr. V Vani
VIT Chennai,SCOPE
Overview
 Entity Relationship Model
 Types of Attributes
 Relationship
 Structural Constraints
 Relational Model
 Relational model Constraints
 Mapping ER model to a relational schema
 Integrity constraints
Data Model
 A diagram that displays a set of tables and
the relationships between them.
The Importance of Data Model
 Blue print: official documentation
Eg. Blue print of house

 Identify what data is important


 Identify what data should be maintained
ER Schema
 ER Model is a semantic data model which
makes it easier for a user to come up
with a good initial description of the data
in an enterprise.
 ER Model is a high-level conceptual data
model.
 ER model is a design or blueprint of a
database.
 ER diagram shows the complete logical
structure of a database.
ER Schema
 Description of a database is called the
database schema.
 Pictorial representation of schema is
called a schema diagram.
 This model is frequently used for the
conceptual design of database
applications.
 Diagrammatic notation associated with
the ER model, known as ER diagrams.
ER Schema
 Notation for ER diagrams and common
pitfalls that occur in schema design.
 Choosing the names for database
schema is based on entity types and
relationship types.
 ER diagram has three main components
1. Entity
2. Attribute
3. Relationship
ERD (Entity Relationship Diagram)
 The major activity of this
phase is identifying entities,
attributes, and their
relationships to construct
model using the Entity
Relationship Diagram.
 Entity  table
 Attribute  column
 Relationship  line
Entity
 Entity:
 "...anything (people, places, objects,
events, etc.) about which we store
information (e.g. supplier, machine tool,
employee, utility pole, airline seat, etc.).”
 Tangible: customer, product
 Intangible: order, accounting receivable
Entity Instance
Entity instance: a single occurrence of an entity.
 6 instances

Student ID Last Name First Name


Entity: student
2144 Arnold Betty
3122 Taylor John
3843 Simmons Lisa
instance 9844 Macy Bill
2837 Leath Heather
2293 Wrench Tim
Attributes

 Attribute:
Attributes are data objects that either
identify or describe entities (property
of an entity).

Eg. Student Id, First name, Last name


Relationships
 Relationship:
 Relationships are associations between entities.
 Typically, a relationship is indicated by a verb connecting
two or more entities.
 Employees are assigned to projects
 Relationships should be classified in terms of cardinality.
 One-to-one, one-to-many, many-to-one, many-to-many
Relationships
WORKS_FOR (between EMPLOYEE, DEPARTMENT)
MANAGES (also between EMPLOYEE, DEPARTMENT)
CONTROLS (between DEPARTMENT, PROJECT)
WORKS_ON (between EMPLOYEE, PROJECT)
SUPERVISION (between EMPLOYEE (as subordinate),
EMPLOYEE (as supervisor))
DEPENDENTS_OF (between EMPLOYEE, DEPENDENT)
Cardinality
 Cardinality:
 The cardinality is the number of occurrences in one entity which
are associated to the number of occurrences in another.

 There are three basic cardinalities (degrees of relationship).

 one-to-one (1:1), one-to-many (1:M), and many-to-many (M:N)


Many-to-one (N:1) Relationship
Many-to-Many (M:N) Relationship
Identifier
“attributes that uniquely identify entity
instances”
 Becomes a PK(primary key) in RDS
 Composite identifiers are identifiers that consi
of two or more attributes
 Identifiers are represented by underlying the
name of the attribute(s)
 Employee (Employee_ID), student (Student_ID)
Classes of attributes
 Simple attribute
 Composite attribute
 Derived attributes
 Single-valued attribute
 Multi-valued attribute
Simple/Composite
attribute
 A simple attribute cannot be subdivided.
 Examples: Age, Gender, and Marital status
 A composite attribute can be further subdivided to
yield additional attributes.
 Examples:
 ADDRESS -- Street, City, State, Zip
 PHONE NUMBER -- Area code, Exchange number
Composite attribute
Derived attribute
 is not physically stored within the database
 instead, it is derived by using an algorithm.
 Example 1: Late Charge of 2%
 MS Access: InvoiceAmt * 0.02
 Example 2: AGE can be derived from the date of birth and the
current date.
 MS Access: int(Date() – Emp_Dob)/365)
Single-valued attribute
 can have only a single (atomic) value.
 Examples:
 A person can have only one social security number.
 A manufactured part can have only one serial number.
 A single-valued attribute is not necessarily a simple attribute.
 Part No: CA-08-02-189935
 Location: CA, Factory#:08, shift#: 02, part#: 189935
Multi-valued attributes
 An attribute can have many values.
 Examples:
 A person may have several college degrees.
 A household may have several phones with different numbers
 A car color
Example - “Movie
Database”
 Entity:
 Movie Star

 Attributes:
 SS#: “123-45-6789” (single-valued)
 Cell Phone: “(661)123-4567, (661)234-5678” (multi-valued)
 Name: “Harrison Ford” (composite)
 Address: “123 Main Str., LA, CA” (composite)
 Gender: “Female” (simple)
 Age: 24 (derived)
Participation
2 types:
a. Total
b. Partial
Keys
 Key is an attribute or collection of
attributes that uniquely identifies an
entity among entity set.
 Super Key
 Candidate Key
 Primary Key
Symbols used in ERD
Rectangles: This Entity Relationship Diagram
symbol represents entity types.
Ellipses : Symbol represent attributes.

Diamonds: This symbol represents


relationship types.

Lines: It links attributes to entity types and


entity types with other relationship types
Primary key: attributes are underlined.

Double Ellipses: Represent multi-valued


attributes
Source:https://www.guru99.com/er-diagram-tutorial-dbms.html
Source:https://www.guru99.com/er-diagram-tutorial-dbms.html
Source:Elmasri
Navathae book@2007
Entities, Attributes, Relation & Keys

Postin
EID Name
g

Employee

Employees Entity Set


Entities, Attributes, Relation & Keys

DID Name HOD

Department

Department Entity Set


Entities, Attributes, Relation & Keys

EID Name Posting DID Name HOD

Employee Works-In Department

Works-ln Relationship Set


Entities, Attributes, Relation & Keys
 In terms of DBMS, an entity is a table or
attribute of a table, a relationship is
relation among tables and their
attributes.
 In Database systems, the term "Table"
highlights the Entity.
 In Database systems, the term "Field"
highlights the Attributes.
Entity Types
 Types of Entities in ER Model
 Strong entity
These shapes are independent from other entities
 Weak entity
Weak entities depend on some other entity type
 Associative entity
Associative entities relate the instances of several
entity types
Strong Entity Set Weak Entity Set

Strong entity set always has a primary key. It does not have enough attributes to build a primary key.

It is represented by a rectangle symbol. It is represented by a double rectangle symbol.

It contains a Primary key represented by the underline symbol. It contains a Partial Key which is represented by a dashed
underline symbol.

The member of a strong entity set is called as dominant entity The member of a weak entity set called as a subordinate entity
set. set.

Primary Key is one of its attributes which helps to identify its In a weak entity set, it is a combination of primary key and
member. partial key of the strong entity set.

In the ER diagram the relationship between two strong entity The relationship between one strong and a weak entity set
set shown by using a diamond symbol. shown by using the double diamond symbol.

The connecting line of the strong entity set with the relationship The line connecting the weak entity set for identifying
is single. relationship is double.

Source:https://www.guru99.com/er-diagram-tutorial-dbms.html
Source:ElmasriNavathae book@2007
Source:ElmasriNavathae book@2007
The (min, max) notation for
relationship constraints

Read the min,max numbers next to the entity type and looking
away from the entity type
Source:ElmasriNavathae book@2007
COMPANY ER Schema Diagram using
(min, max) notation

Source:ElmasriNavathae book@2007
Keys
 Key is an attribute or collection of
attributes that uniquely identifies an
entity among entity set.
 For example, the roll_number of a
student makes him/her identifiable
among students.
 Super Key − A set of attributes (one or more) that
collectively identifies an entity in an entity set.
 Candidate Key − A minimal super key is called a candidate
key. An entity set may have more than one candidate key.
 Primary Key − A primary key is one of the candidate keys
chosen by the database designer to uniquely identify the
entity set.
ER Model to Relational Schema
ER Model
Steps for converting ER Model to
Relational Schema or Tables

Step1: Convert all strong entity sets into relations


Step2: Mapping weak Entity types
Step3: Mapping 1:1 Relationships types
Step4: Mapping 1:N Relationships types
Step5: Mapping M:N Relationships types
Step6: Mapping multi valued attributes
Step1:Convert all strong entity sets into
relations

 Covert all strong entities into separate tables or relations


 Exclude multivalued attributes
Step2: Mapping weak entity types

 Create separate relation and include all simple attributes


 Exclude multi valued attributes.
 Add Primary Key of the owner entity set into weak entity set
Step3: Mapping 1:1 Relationships types

 Identify the entity sets with total participation (say entity S)


 Add Primary key of R entity into S entity as Foreign key
Step4: Mapping 1:N Relationships types

 Identify the entity sets with total participation (say entity S)


 Add Primary Key of R entity in S entity as Foreign Key
Step5: Mapping M:N Relationships types

 Create a separate relation containing Primary Key of both entity


between which we have M:N relationship.
 Also consider the descriptive attributes if it has.
Step6: Mapping Multi valued
Attributes

 Create a separate relation for each and every multi valued


attributes.

 That relation or table will be having key attribute from entity set
which it as attached.
Relational Schema
(for Company ER model)

You might also like