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

Lecture 3a - Conceptual Data Modeling

The document discusses conceptual data modeling and the entity-relationship (E-R) model. It provides an overview of E-R modeling constructs such as entities, attributes, relationships, and cardinalities. It also presents an example E-R diagram for Pine Valley Furniture Company and describes the entities, attributes, and relationships in the diagram. The document outlines guidelines for conceptual data modeling, including defining entities, attributes, and relationships as well as gathering and representing business rules.

Uploaded by

Hurair khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Lecture 3a - Conceptual Data Modeling

The document discusses conceptual data modeling and the entity-relationship (E-R) model. It provides an overview of E-R modeling constructs such as entities, attributes, relationships, and cardinalities. It also presents an example E-R diagram for Pine Valley Furniture Company and describes the entities, attributes, and relationships in the diagram. The document outlines guidelines for conceptual data modeling, including defining entities, attributes, and relationships as well as gathering and representing business rules.

Uploaded by

Hurair khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

Ch 

Database Management Systems

Sumayyea Salahuddin (Lecturer)
Dept. of Computer Systems Eng.
UET Peshawar
Ch 2
Overview
• Conceptual Data Modeling/Schema in Organization
– Entity Description
– Modeling Business Rules
– E-R Model Constructs
• Modeling ENTITIES
• Modeling ATTRIBUTES
• Modeling RELATIONSHIPS
• Modeling CARDINALITIES
– Examples
– Case Study: Pine Valley Furniture Company

Database Management Systems, Spring 2021, DCSE. 2
Ch 2
E‐R Model Overview
• The E-R model is a data model that describes relationships
(1:1, 1:M, M:M) among entities at the conceptual level with
the help of E-R diagrams

• E-R diagram is a diagram that shows the E-R model's entities,


attributes, relations, connectivities and cardinalities

Database Management Systems, Spring 2021, DCSE. 3
Pine Valley Furniture Company (PVFC) Ch 2
Example E‐R Diagram

Figure 2‐1: Sample E‐R Diagram
Database Management Systems, Spring 2021, DCSE. Version 5 4
Ch 2
Basic E‐R Notation

Attribute
Symbols
Entity
Symbols

Relationship
Symbols

Figure 2‐2: Basic E‐R Notation
Database Management Systems, Spring 2021, DCSE. 5
Pine Valley Furniture Company (PVFC) Ch 2
Example ERD Entity Description

Database Management Systems, Spring 2021, DCSE. 6
Pine Valley Furniture Company (PVFC) Ch 2
Example ERD Business Rules

Database Management Systems, Spring 2021, DCSE. 7
Pine Valley Furniture Company (PVFC) Ch 2
Business Rule Grammar & Example
• Business rules roughly follows certain grammar, that is:

• Example:

Database Management Systems, Spring 2021, DCSE. 8
Ch 2
Modeling Organizational Rules
• Identify and understand those rules that govern data
• Represent those rules so that they can be unambiguously
understood by information systems developers and users
• Implement those rules in database technology

Database Management Systems, Spring 2021, DCSE. 9
Ch 2
Business Rule
• A statement that defines or constrains some aspect of the
business. It is intended to assert business structure or to
control or influence the behavior of the business.
1) A student may register for a section of a course only if he or
she has successfully completed the prerequisites for that
course
2) A preferred customer qualifies for a 10 percent discount,
unless he has an overdue account balance
• In the database world, it has been more common to use the
related term integrity constraint when referring to such rules.
– referring to maintaining valid data values and relationships in
the database.-

Database Management Systems, Spring 2021, DCSE. 10
Ch 2
Scope of Business Rule
• Friday is business casual dress day
– policy
– no impact on database.

• A student may register for a section of a course only if he or


she has successfully completed the prerequisites for that
course.
– constrains the transactions processed against the database
– causes any transaction to be rejected that attempts to register a
student who does not have the necessary prerequisites

Database Management Systems, Spring 2021, DCSE. 11
Ch 2
Characteristics of Good Business Rules

Database Management Systems, Spring 2021, DCSE. 12
Ch 2
Gathering Business Rules (1)
• Appear in descriptions of business functions, events, policies,
units, stakeholders, and other objects.

• Descriptions can be found in interview notes from individual


and group information systems requirements collection
sessions, organizational documents (e.g., personnel manuals,
policies, contracts, marketing brochures, and technical
instructions)

• Identified by asking questions about the who, what, when,


where, why, and how of the organization

Database Management Systems, Spring 2021, DCSE. 13
Ch 2
Gathering Business Rules (2)
• Be persistent in clarifying initial statements of rules because
initial statements may be vague or imprecise.

• Precise rules are formulated from an iterative inquiry process.

• Asking proper questions:


– "Is this always true?"
– "Are there special circumstances when an alternative occurs?"
– "Are there distinct kinds of that person?"
– "Is there only one of those or are there many?" and
– "Is there a need to keep a history of those, or is the current
data all that is useful?"

Database Management Systems, Spring 2021, DCSE. 14
Ch 2
Data Names and Definition
• Give entities, relationships, and attributes clear and distinct
names and definitions.

• Data Name:
– Related to business, not technical (hardware or software),
characteristics: e.g. Customer while File10, Bit7, etc. not good
– Be meaningful: avoid using generic words such as has, is, or it
– Be unique: Home Address vs. Campus Address
– Be readable: GPA vs. Average Grade Relative To A
– Be composed of words taken from an approved list: Cust for
Customer
– Be repeatable: Employee Birth Date and Student Birth Date
– Follow a standard syntax.

Database Management Systems, Spring 2021, DCSE. 15
Ch 2
Data Definition
• Term
– A word or phrase that has a specific meaning for the business
– Example: course, section, flight, reservation, passenger, rental
car, etc.
– Key words
– Must be defined carefully & concisely
• Fact
– An association between two or more terms
– Example 1: A course is module of instruction in a particular
subject area.
– Example 2: A customer may request a model of car from a rental
branch on a particular date.

Database Management Systems, Spring 2021, DCSE. 16
Ch 2
Guidelines for Good Data Definition
• On Page: 66‐67, some mentioned here
• Gathered from the same sources as all requirements for 
information systems
• Accompanied by diagrams (e.g. ERD)
• Stated in the singular and explain what the data is
– Use commonly understood terms and abbreviations
– Where, when, and how the data are created or calculated in the 
organization
– Whether the data are static or changes over time
– Whether the data are singular or plural in its atomic form
– Who determines the value for the data
– Who owns the data
– Whether the data are optional or whether empty/null values are allowed
– Whether the data can be broken down into more atomic parts or are often 
combined with other data into some more composite or aggregate form

Database Management Systems, Spring 2021, DCSE. 17
Ch 2
Entity
• Entity – A person, place, object, event, or concept in the user
environment about which the organization wishes to maintain
data.

• Entity Type – A collection of entities that share common


properties or characteristics

• Entity Instance – A single occurrence of entity type

Database Management Systems, Spring 2021, DCSE. 18
Ch 2
Entity Type Vs. Entity Instance

Figure 2‐3: Entity Type EMPLOYEE with two instances

Database Management Systems, Spring 2021, DCSE. 19
Ch 2
What should an Entity Be?
• SHOULD BE
– An object that will have many instances in the database
– An object that will be composed of multiple attributes
– An object that we are trying to model

• SHOULD NOT BE
– A user of the database system
– An output of the database system (e.g. a report)

Database Management Systems, Spring 2021, DCSE. 20
Ch 2
Example

Figure 2‐4: Example of Inappropriate Entities
Database Management Systems, Spring 2021, DCSE. 21
Ch 2
Strong vs. Weak Entities & Identifying 
Relationships
• Strong Entity
– Exists independently of other types of entities
– Has its own unique identifier
– Represented with single–line rectangle

• Weak Entity
– Dependent on a strong entity… can’t exist on its own
– Does not have a unique identifier
– Represented with double–line rectangle

• Identifying Relationship
– Link strong entities to weak entities
– Represented with double line diamond

Database Management Systems, Spring 2021, DCSE. 22
Ch 2
Strong & Weak Entities

Figure 2‐5: Example of 
Weak Entity

Database Management Systems, Spring 2021, DCSE. 23
Ch 2
Attributes
• Attribute – A property or characteristic of an entity or
relationship type that is of interest to the organization

• Required Attribute – An attribute that must have a value for


every entity (or relationship) instance with which it is
associated

• Optional Attribute – An attribute that may not have a value for


every entity (or relationship) instance with which it is
associated
When we represent entities in a database, we actually store only the attributes.
Database Management Systems, Spring 2021, DCSE. 24
Ch 2
Required & Optional Attributes

Figure 2‐6: Entity Type STUDENT with required and optional attributes

Database Management Systems, Spring 2021, DCSE. 25
Ch 2
Classification of Attributes
• Classification of attributes
– Simple (e.g. age, sex, marital status) versus Composite (e.g.
address, phone number) Attribute
– Single-Valued (e.g. NIC number, serial number of a manufactured
part SE-08-02-189935) versus Multi- valued (e.g. a house having
several phones, a person having several degrees) Attribute
– Stored versus Derived (whose values are calculated from other
attributes e.g. age is current date minus DOB. In Access:
INT((Date() EMP_DOB)/365)) Attributes
– Identifier Attributes

Database Management Systems, Spring 2021, DCSE. 26
Ch 2
Composite Attribute
An Attribute
broken into
component parts

Figure 2‐7: Example of  
Composite Attribute

Database Management Systems, Spring 2021, DCSE. 27
Ch 2
Entity with Multi‐Valued & Derived 
Attributes
Multi-valued:
An employee can
have more than
one skill

Derived:
From date employed
& current date

Figure 2‐8: Example of  
Multivalued & Derived
Attribute
Database Management Systems, Spring 2021, DCSE. 28
Ch 2
Identifiers (Keys)
• Identifier (Key) – An attribute (or combination of attributes)
that uniquely identifies individual instances of an entity type
• Simple Key versus Composite Key
• Candidate Key – an attribute that could be a key… satisfies
the requirements for being key

Database Management Systems, Spring 2021, DCSE. 29
Ch 2
Key Attribute

Key is
underlined

Figure 2‐9a: Simple 
Identifier Attribute

Database Management Systems, Spring 2021, DCSE. 30
Ch 2
Composite Key Attribute

Key is
composed of
two sub-parts

Figure 2‐9b: Composite 
Identifier Attribute

Database Management Systems, Spring 2021, DCSE. 31
Ch 2
Characteristics of Identifiers
• Will not change in value
• Will not be null
• No intelligent identifier (for instance containing locations or
people that might change)
• Substitute new, simple keys for long, composite keys

Database Management Systems, Spring 2021, DCSE. 32
Ch 2
Relationships
• Relationship Types vs. Relationship Instances
– The relationship type is modeled as the diamond and lines between
entity types… the instance between specific entity instances
• Relationships can have attributes
– These describes features pertaining to the association between the
entities in the relationship
• Two entities can have more than one type of relationship
between them (multiple relationships)
• Associative Entity – combination of relationship and entity
– More on this later

Database Management Systems, Spring 2021, DCSE. 33
Ch 2
Relationship Type

Figure 2-10a: Relationship Type


Database Management Systems, Spring 2021, DCSE. 34
Ch 2
Relationship Instances

Figure 2-10b: Relationship Instances


Database Management Systems, Spring 2021, DCSE. 35
Ch 2
Table 2‐2

Database Management Systems, Spring 2021, DCSE. 36
Ch 2
Binary Relationship with an Attribute

Figure 2‐11a: Attribute 
on a Relationship

Here date_completed attribute pertains specifically to the employee’s


completion of a course… it is an attribute of the relationship

Database Management Systems, Spring 2021, DCSE. 37
Ch 2

Associative Entities
• It’s an entity – it has attributes

• And it’s a relationship – it links entities together

• When should a relationship with attributes instead be an


associative entity?
– All relationships for the associative entity should be many
– The associative entity could have meaning independent of the other
entities
– The associative entity preferably has a unique identifier, and should also
have other attributes
– The associative may be participating in other relationships other than
the entities of the associated relationship
– Ternary relationships should be converted to associative entities
Database Management Systems, Spring 2021, DCSE. 38
Ch 2
An Associative Entity (Certificate)

Figure 2‐11b: 
Associative 
Entity

Associative entity involves a rectangle with a diamond inside. Note


that the many-to-many cardinality symbols face toward the
associative entity and not toward the other entities.

Database Management Systems, Spring 2021, DCSE. 39
Ch 2
Degree of Relationships
• Degree of Relationship – The number of entity types that
participate in a relationship
– Unary Relationship
– Binary Relationship
– Ternary Relationship

Database Management Systems, Spring 2021, DCSE. 40
Ch 2
Degree of Relationships

One entity
Entity of two Entity of three
related to
different different types
another of the
types related related to each
same entity
to each other. other.
type.

Database Management Systems, Spring 2021, DCSE. 41
Ch 2
Unary Relationships

Figure 2‐12a: Unary Relationships

Database Management Systems, Spring 2021, DCSE. 42
Ch 2
Unary Relationship with an Attribute

Unary relationship with an attribute (many-to-many relationship)

Representing a bill– of –material


structure

Figure 2‐13a: Unary M:M Relationship

Database Management Systems, Spring 2021, DCSE. 43
Ch 2
Example

Figure 2‐13b: Two ITEM bill‐of‐materials structure instances

Database Management Systems, Spring 2021, DCSE. 44
Ch 2
An Associative Entity (Bill of Material 
Structure)

Figure 2‐13c: An
Associative Entity

This could just be a relationship with attributes… it’s a judgment call

Database Management Systems, Spring 2021, DCSE. 45
Ch 2
Binary Relationships

Figure 2‐12b: Binary
Relationships

Database Management Systems, Spring 2021, DCSE. 46
Ch 2
Ternary Relationships

Figure 2‐12c: Ternary Relationship
Database Management Systems, Spring 2021, DCSE. 47
Ch 2
Cardinality of Relationships
• Cardinality Constraints - the number of instances of one entity
that can or must be associated with each instance of another
entity.

• Minimum Cardinality
– If zero, then optional
– If one or more, then mandatory

• Maximum Cardinality
– The maximum number

Database Management Systems, Spring 2021, DCSE. 48
Ch 2
Cardinality of Relationships
• One-to-One
– Each entity in the relationship will have exactly one related entity

• One-to-Many
– An entity on one side of the relationship can have many related entities,
but an entity on other side will have a maximum of one related entity

• Many-to-Many
– Entities on both sides of the relationship can have many related entities
on the other side

Database Management Systems, Spring 2021, DCSE. 49
Ch 2
Cardinality

Database Management Systems, Spring 2021, DCSE. 50
Ch 2
Minimum & Maximum Cardinalities 
Example
Basic relationship with only maximum cardinalities:

Relationship with cardinality constraints:

Figure 2‐16: Cardinality Constraints
Database Management Systems, Spring 2021, DCSE. 51
Ch 2
Example of Cardinality Constraints

Figure 2‐17: Examples of
Cardinality Constraints

Database Management Systems, Spring 2021, DCSE. 52
Ch 2
Ternary Relationship with Attributes

Database Management Systems, Spring 2021, DCSE. 53
Ch 2
Ternary Relationship as an Associative 
Entity

Figure 2‐18: Examples of Cardinality Constraints
Database Management Systems, Spring 2021, DCSE. 54
Ch 2
Attribute – Both Multi‐valued & 
Composite
This is an
example of
time-stamping

Figure 2‐19: Simple Example 
of Time Stamping

Database Management Systems, Spring 2021, DCSE. 55
Ch 2
Example of Multiple Relationships
Entities can be related to one another in more than one way…

Figure 2‐21a: Employees and Departments

Database Management Systems, Spring 2021, DCSE. 56
Ch 2
Professors & Courses

Here, max cardinality


constraint is 4.

Database Management Systems, Spring 2021, DCSE. 57
Ch 2
Professors & Courses (Cont.)

Here, min cardinality


constraint is 2.

Figure 2‐21a: Professors & Courses

Database Management Systems, Spring 2021, DCSE. 58
Ch 2
Multi‐valued Attribute vs. Relationship

Alternative Approaches

Database Management Systems, Spring 2021, DCSE. 59
Ch 2
Multi‐valued Attribute vs. Relationship 
(1)

Database Management Systems, Spring 2021, DCSE. 60
Ch 2
Multi‐valued Attribute vs. Relationship 
(2)

Database Management Systems, Spring 2021, DCSE. 61
Ch 2
Multi‐valued Attribute vs. Relationship 
(3)

Database Management Systems, Spring 2021, DCSE. 62
Ch 2
Summary
• Covered Conceptual Data Modeling/Schema in detail
• Covered Business Rules
• Covered ERD and its constructs in detail using examples

Database Management Systems, Spring 2021, DCSE. 63

You might also like