SlideShare a Scribd company logo
1 of 59
Data Modeling
(Part – 1)
Presented by:
Mr. S. Christalin Nelson
2/20/2024 Christalin Nelson | Systems Cluster | SOCS 2
At a Glance
• Terminologies & Constraints
• Using High-Level Conceptual Data Models for Database Design
• Sample Database Application
• Entity Types, Entity Sets, Attributes, Keys, and Value Sets
• Relationship Types, Relationship Sets, Roles, and Structural Constraints
• Weak Entity Types
• Refining ER Design for COMPANY Database
• ER Diagrams, Naming Conventions, and Design Issues
• Relationship Types of Degrees Higher than Two
3
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
3 of 59
2/20/2024
Few Terminologies (1/2)
• Domain
– Consists of Name, Data type, Format
– Set of atomic values
• Several Attributes can have the same domain
– Example: Domain named "Phone number" can have attributes home_phone,
office_phone, mob_phone
• Relation – Table name
• Relation Schema (or) Relation Intension
– Includes Table Name, List of Attributes
• Relation State (or) Relation Extension
• Relation instance – Single row (or) tuple
Christalin Nelson | Systems Cluster | SOCS
4 of 59
2/20/2024
Few Terminologies (2/2)
• Degree or Arity – No. of Attributes
• Tuples are considered as facts about a relation (or) values satisfying the predicate
• Relations represent
– Facts about entities
– Facts about relationships
• Tuple Ordering
• Attribute Ordering
• Basic Relational model
– Composite and Multivalued attributes are not allowed
– Also called a flat relational model
Christalin Nelson | Systems Cluster | SOCS
5 of 59
2/20/2024
Types of Constraints (1/6)
• Inherent model based constraints or Implicit constraints
– Example:
• A relation cannot have duplicate tuples
• Schema-based constraints or Explicit constraints
– Example:
• Domain constraints
• Constraints on NULLs
• Key constraints
• Entity Integrity constraints
• Referential integrity constraints
Christalin Nelson | Systems Cluster | SOCS
6 of 59
2/20/2024
Types of Constraints (2/6)
• Application-based or semantic constraints or business rules
– Specified and enforced on a relational database or by using general-purpose constraint
specification language
– Example
• The salary of an employee should not exceed salary of employee’s supervisor at DB update
– Mechanisms: Triggers, Assertions
• Data Dependencies
– Example:
• Functional and Multivalued dependencies
– Used with Normalization
Christalin Nelson | Systems Cluster | SOCS
7 of 59
2/20/2024
Types of Constraints (3/6)
• State constraints (or) Static constraints
– Constraints discussed so far
– Define the constraints that a valid state of DB must satisfy
• Transition constraints (or) Dynamic constraints
– Enforced by application programs or specified using active rules and triggers
– Example:
• Salary of an employee can only increase
Christalin Nelson | Systems Cluster | SOCS
8 of 59
2/20/2024
Types of Constraints (4/6)
• Domain Constraint
– The value of each attribute must be an atomic value
• Meanings for NULL values
– (1) Not Applicable
• E.g. Person with no college degree would have “null” for “College_degrees” attribute
– (2) Unknown value – Value exists but is missing or unavailable
• E.g. Height attribute of a person
– (3) Unknown value – Does not know if value exists
• E.g Home_phone attribute of a person
Christalin Nelson | Systems Cluster | SOCS
9 of 59
2/20/2024
Types of Constraints (5/6)
• Key constraints
– Specified on individual relations
– Every table has at least one “Superkey” (subset of attributes)
– “Superkey” can have redundant attributes
– “Key” cannot have redundant attributes
– Any “Superkey” formed from a single attribute is also a “Key”
– Rules
• (1) “Superkey” & “Key” for each tuple should be distinct => “Unique” constraint
• (2) “Key” is a “minimal superkey”
– i.e. Removal of an attribute will compromise “Unique” constraint
– A relation schema may have more than one “key” => termed as “Candidate key”
• One candidate is identified as “Primary key”
Christalin Nelson | Systems Cluster | SOCS
10 of 59
2/20/2024
Types of Constraints (6/6)
• Entity Integrity constraint
– Specified on individual relations
– No “Primary key” value can be NULL
• Referential integrity constraints
– Specified between two relations
– “Foreign key” in a dependent relation
– Rules
• (1) Attributes of FK should have the same domain as of PK
• (2) Value of FK = value of PK (or) null
– FK can refer to another tuple in its own relation
Christalin Nelson | Systems Cluster | SOCS
11 of 59
2/20/2024
Data Modeling using ER Model
• Data Application
– Database, Application program that implements DB Queries and updates
– DB design + Software Engineering (Design, Implementation, Testing of Appln.)
• Entity-Relationship (ER) model
– Popular high-level conceptual data model
– ER diagrams
• Diagrammatic notation associated with the ER model
• Enhanced-ER (EER) model
– Includes concepts such as specialization, generalization, inheritance, and union types
(categories)
• Unified Modeling Language (UML)
– Object modeling
Christalin Nelson | Systems Cluster | SOCS
12 of 59
2/20/2024
Using High-Level Conceptual Data Models (1/4)
• Requirements collection and analysis
– DB designers interview prospective DB users to understand and document data
requirements & functional requirements
• Result-1: Concise set of users’ requirements specified in a detailed and complete form
• Result-2: User-defined operations/transactions applied to the DB
– Note:
• Techniques used to specify functional requirements in Software design include DFD,
Sequence diagrams, scenarios
• Functional Analysis
– Identify high-level user queries and operations
Christalin Nelson | Systems Cluster | SOCS
13 of 59
Main phases of database design
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
14 of 46
14 of 59
2/20/2024
Using High-Level Conceptual Data Models (3/4)
• Conceptual design
– Includes
• Concise description of Data requirements
• Detailed descriptions of entity types, relationships, and constraints
• Use the basic data model operations to specify high-level user queries and operations
• Note: Does not include implementation details
– Result: Conceptual schema of high-level data model
– Used to communicate with non-technical users
– Used as a reference to ensure that all users’ data requirements are met and do not
conflict
Christalin Nelson | Systems Cluster | SOCS
15 of 59
2/20/2024
Using High-Level Conceptual Data Models (4/4)
• Logical design (or) data model mapping
– Transform Conceptual schema from High-level data model into Implementation data
model
• Actual implementation of DB using a commercial DBMS with an implementation data
model (like Relational or Object-relational DB model)
– Result: DB schema (Conceptual/Logical Schema in the data model of a specific DBMS)
– Often automated or semi-automated within the DB design tools
• Physical design phase
– Internal storage structures, file organizations, indexes, access paths, and physical
design parameters for the database files are specified
Result: Internal schema
• Application program development
Christalin Nelson | Systems Cluster | SOCS
16 of 59
2/20/2024
Sample Database Application
• COMPANY Database – Description
– Employee
• Each employee has a name, social security number, address, salary, sex (gender), and birth date
• Each employee works for one department and can work on several projects that other
departments can control – Track the current no. of hours per week that an employee works on
each project
• Track the direct supervisor of each employee (who is another employee)
• A particular employee manages the department – Track the start date when an employee began
managing the department
– Department
• Each department has a unique name, a unique number and may have several locations
• Can control several projects
– Project
• Each project has a unique name, a unique number, and a single location
– Dependents
• Each dependent has a first name, sex (gender), birth date, and relationship to the employee.
• Track the dependents of each employee for insurance purposes
Christalin Nelson | Systems Cluster | SOCS
17 of 59
18
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
18 of 59
2/20/2024
Entities and their Attributes (1/5)
• ER model describes data as Entities, Relationships, and Attributes
• Entities
– Things in the real world with independent existence
• Attributes
– Properties that describe an entity
– Types
• Composite vs. Simple (atomic) attributes
• Single-valued vs. Multi-valued attributes
• Stored vs. Derived attributes
• NULL values (Not Applicable & Unknown)
• Complex attributes
Christalin Nelson | Systems Cluster | SOCS
19 of 59
2/20/2024
Entities and their Attributes (2/5)
• Composite vs. Simple (atomic) attributes
– Attributes that are not divisible are called simple (or) atomic attributes
– Composite attributes are divided into smaller subparts (basic attributes)
• Useful to model situations in which a user sometimes refers to composite attribute as a
unit but at other times refers specifically to its components
• Value of composite attribute = Concatenation of values of its component simple attributes
– Components of a composite attribute are given within parentheses () & separated with commas
» Example: Address (Street_address(Number, Street, Apartment_number), City, State, Zip)
• Can form a hierarchy (Pic)
Christalin Nelson | Systems Cluster | SOCS
20 of 59
2/20/2024
Entities and their Attributes (3/5)
• Single-valued vs. Multi-valued attributes
– Singled-valued attributes have a single value for a particular entity
• Example: “Age” is a single-valued attribute of a person
– Multi-valued attributes have a set of values for the same entity
• May have lower & upper bounds to constrain the number of values allowed for each entity
• Multivalued attributes are mentioned using braces {}
– Example: “color” attribute for a car is {blue, red}
Christalin Nelson | Systems Cluster | SOCS
21 of 59
2/20/2024
Entities and their Attributes (4/5)
• Stored vs. Derived attributes
– Values of Stored attributes are given by the user and stored
– Values of Derived attributes should be derived
• Derived from the related attributes of an entity
– Example: “Age” and “Birth_date” attributes of a person
» Age attribute (Derived attribute), Birth_date attribute (Stored attribute)
• Derived from related entities
– Example: Attribute “Number_of_employees” of a DEPARTMENT entity can be derived by
counting the number of employees working for that department
Christalin Nelson | Systems Cluster | SOCS
22 of 59
2/20/2024
Entities and their Attributes (5/5)
• Complex attributes
– Composite and multivalued attributes can be nested arbitrarily
– Example: Attribute “Address_phone” of a person who can have >1 residence, and each
residence can have a single address and multiple phones
{
Address_phone (
{Phone(Area_code, Phone_number)},
Address(Street_address(Number, Street, Apartment_number), City, State, Zip)
)
}
Note: Here “Address” and “Phone” are composite attributes
Christalin Nelson | Systems Cluster | SOCS
23 of 59
2/20/2024
Entity Types, Entity Sets, Keys, and Value Sets (1/4)
• Entity type
– Collection (or set) of entities that have the same attributes
– Describes Schema (Intension) for the set of entities
Christalin Nelson | Systems Cluster | SOCS
24 of 59
2/20/2024
Entity Types, Entity Sets, Keys, and Value Sets (2/4)
• Key attribute
– Table has one/more attributes whose values are distinct for each entity in entity set
• Some entity types have >1 key attribute
• Composite Key Attribute: Combination of attribute values must be distinct for each entity
– Satisfies the key or uniqueness constraint
– Note:
• There is no concept of a primary key in the ER model
• The primary key will be chosen during mapping to a relational schema (Relational Model)
• Weak Entity Type
– An entity type without even one key attribute
Christalin Nelson | Systems Cluster | SOCS
25 of 59
Entity type
Rectangular box enclosing
the entity type name
Attribute names
Enclosed in ovals & are
attached to their entity
type by straight lines
Composite attributes
Attached to their
component attributes by
straight lines
Multivalued attributes
Displayed in double ovals
Key attribute
Its name underlined inside
the oval
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
26 of 59
2/20/2024
Entity Types, Entity Sets, Keys, and Value Sets (4/4)
• Value sets (or domain of values) of Attributes
– Set of values that may be assigned to that attribute for each entity
– Note:
• Value sets are not displayed in ER diagrams
• Specified using the basic data types available in most programming languages
– An attribute (A) of entity set (E) whose value set is V can be defined as a function from E to the
power set P(V) of V
• A : E → P(V)
– Value of attribute(A) for entity (e) is A(e)
• NULL value is represented by empty set
• For single-valued attributes, A(e) is restricted to a singleton set for each entity(e) in E
• There is no restriction on multivalued attributes
• For a composite attribute (A), the value set V is the power set of the Cartesian product of P(V1),
P(V2), ..., P(Vn), where V1, V2, ..., Vn are the value sets of the simple component attributes that
form A:
– V = P (P(V1) × P(V2) × ... × P(Vn))
Christalin Nelson | Systems Cluster | SOCS
27 of 59
2/20/2024
Sample Database Application
• COMPANY Database – Description
– Employee
• Each employee has a name, social security number, address, salary, sex (gender), and birth date
• Each employee works for one department and can work on several projects that other
departments can control – Track the current no. of hours per week that an employee works on
each project
• Track the direct supervisor of each employee (who is another employee)
• A particular employee manages the department – Track the start date when an employee began
managing the department
– Department
• Each department has a unique name, a unique number and may have several locations
• Can control several projects
– Project
• Each project has a unique name, a unique number, and a single location
– Dependents
• Each dependent has a first name, sex (gender), birth date, and relationship to the employee.
• Track the dependents of each employee for insurance purposes
Christalin Nelson | Systems Cluster | SOCS
28 of 59
2/20/2024
Initial Conceptual Design of COMPANY Database
Christalin Nelson | Systems Cluster | SOCS
29 of 59
2/20/2024
Relationship Types, Relationship Sets (1/3)
• Relationship
– An attribute of one entity type refers to another entity type – represent references as
relationships, and not as attributes
• Relationship Types
– As with Entity types & Entity sets, a Relationship type and its corresponding
Relationship set are referred to by the same name, R
• A relationship type(R) among ‘n’ entity types E1, E2, ..., En defines a set of associations (or) a
relationship set among entities from these entity types
• Each relationship instance (ri) in R is an association of entities, where the association
includes exactly one entity from each participating entity type
– Each of the entity types E1, E 2, ..., En is said to participate in the relationship type R; similarly,
each of the individual entities e1, e2, ..., en is said to participate in the relationship instance ri =
(e1, e2, ..., en).
Christalin Nelson | Systems Cluster | SOCS
30 of 59
2/20/2024
Relationship Types, Relationship Sets (2/3)
• Example:
– Consider a relationship type WORKS_FOR between two entity types EMPLOYEE and
DEPARTMENT, which associates each employee with the department for which the
employee works in the corresponding entity set
• Each relationship instance in the relationship set WORKS_FOR associates one EMPLOYEE
entity and one DEPARTMENT entity
Christalin Nelson | Systems Cluster | SOCS
31 of 59
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
32 of 59
2/20/2024
Relationship Degree
• Degree of a relationship type
– Number of participating
entity types
– Examples
• WORKS_FOR relationship is
of degree two (Binary)
• SUPPLY relationship is of
degree three (Ternary)
Christalin Nelson | Systems Cluster | SOCS
33 of 59
2/20/2024
Relationship as Attributes
• Binary relationship type can be thought of in terms of attributes
– Consider WORKS_FOR relationship type
• The attribute called ‘Department’ of EMPLOYEE entity type, where the value of
‘Department’ for each EMPLOYEE entity is a reference to the DEPARTMENT entity for which
that employee works.
– The concept of representing relationship types as attributes is used in a class of data
models called functional data models
• In object DBs, relationships can be represented by reference attributes, either in one
direction or in both directions as inverses
• In relational DBs, “foreign keys” are a type of reference attribute used to represent
relationships
Christalin Nelson | Systems Cluster | SOCS
34 of 59
2/20/2024
Role Names and Recursive Relationships (1/2)
• Role names
– Role name signifies role that a participating entity plays in each relationship instance
– Example:
• In WORKS_FOR relationship type, EMPLOYEE plays the role of employee/worker and
DEPARTMENT plays the role of department/employer
• Recursive relationships
– The same entity type participates in >1 relationship types in different roles
– The role name should be specified
– Example:
• SUPERVISION relationship type relates an employee to a supervisor, where both employee
and supervisor entities are members of the same EMPLOYEE entity set. Here EMPLOYEE
entity type participates twice in SUPERVISION in the role of supervisor & role of supervisee
Christalin Nelson | Systems Cluster | SOCS
35 of 59
36
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
36 of 59
2/20/2024
Binary Relationship Constraints (1/5)
• The constraints limit the possible combinations of entities that may participate in
the corresponding relationship set
• Types
– Cardinality ratio
– Participation constraint
• Cardinality ratio
– Specifies the maximum no. of relationship instances that the entity can participate in
– Possible cardinality ratios for binary relationship types are 1:1, 1:N, N:1, and M:N
– Example: WORKS_FOR binary relationship type, DEPARTMENT:EMPLOYEE is of
cardinality ratio 1:N
• Each department can be related to (employs) any number of employees, but an employee
can be related to (work for) only one department
Christalin Nelson | Systems Cluster | SOCS
37 of 59
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
38 of 59
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
39 of 59
2/20/2024
Binary Relationship Constraints (4/5)
• Participation constraint
– Specifies whether the existence of an entity depends on it being related to another
entity via relationship type
– Specifies the minimum no. of relationship instances that each entity can participate in
(sometimes called minimum cardinality constraint)
– Types: Total & Partial
• Examples:
– A company policy states that “every employee must work for a department”. An employee entity
can exist only if it participates in at least one WORKS_FOR relationship instance. This is called
Total Participation (or) Existence Dependency.
– Every employee is not expected to manage a department. The participation of EMPLOYEE in the
MANAGES relationship type is Partial Participation.
Christalin Nelson | Systems Cluster | SOCS
40 of 59
2/20/2024
Binary Relationship Constraints (5/5)
• Structural Constraints
– Cardinality ratio and Participation Constraints are together considered as structural
constraints of a relationship type
• ER Notation
– Cardinality ratios: Display 1, M, and N on the diamonds
– Total participation: Double line connecting participating entity type to the relationship
– Partial participation: Single line
• Note:
– Either specify no minimum (partial participation) or a minimum of one (total participation)
– Specify a specific minimum number on participation in the relationship, such as 4 or 5
Christalin Nelson | Systems Cluster | SOCS
41 of 59
2/20/2024
Attributes of Relationship Types (1/2)
• Relationship types can also have attributes, similar to those of entity types.
– Example
• ‘Hours’ attribute for the WORK_ON relationship type to track the number of hours per
week that an employee works on a particular project
• ‘Start_date’ attribute for the MANAGES relationship type to track the date on which a
manager started managing a department via an attribute
Christalin Nelson | Systems Cluster | SOCS
42 of 59
2/20/2024
Attributes of Relationship Types (2/2)
• Migration of Attribute of Relation Type => Attribute of Entity Type
– Attributes of 1:1 relationship types => can be migrated to any one entity type
• Example: ‘Start_date’ attribute for MANAGES relationship can be an attribute of either
EMPLOYEE or DEPARTMENT, although conceptually it belongs to MANAGES
– Attributes of 1:N relationship types => can be migrated only to entity type on the N-
side of the relationship
• Example: If WORKS_FOR relationship has an attribute ‘Start_date’ that indicates when an
employee started working for a department, this attribute can be included as an attribute
of EMPLOYEE
– For M:N relationship types => No Migration
• Example: The value of ‘Hours’ attribute of the M:N relationship WORKS_ON is determined
by an employee-project combination and not separately by either entity
Christalin Nelson | Systems Cluster | SOCS
43 of 59
2/20/2024
Weak Entity Type (1/4)
• Entity Type that do not have key attributes of their own
– vs. Strong Entity Type
• Identifying relationship
– Relates weak entity type (Child or subordinate entity type) to Owner (Parent or
Dominant) entity type
• Entities of a weak entity type are identified by being related to specific entities from owner
– Always has a total participation constraint or existence dependency
• Note: Not every existence dependency results in a weak entity type
– Example: DRIVER_LICENSE entity cannot exist unless it is related to a PERSON entity, even
though it has its own key (License_number). Hence is not a weak entity.
Christalin Nelson | Systems Cluster | SOCS
44 of 59
2/20/2024
Weak Entity Type (2/4)
• Example
– Entity type DEPENDENT is related to EMPLOYEE via a 1:N relationship. Each employee
entity is said to OWN the dependent entities that are related to it.
• Note: Two dependents of two distinct employees may, by chance, have the same values for
Name, Birth_date, Sex, and Relationship, but they are still distinct entities. They are
identified as distinct entities ONLY after determining the employee entity to which each
dependent is related.
• Partial key or Discriminator
– Attribute that uniquely identifies weak entities that are related to same owner entity
– Example: The attribute ‘Name’ of DEPENDENT is the partial key
Christalin Nelson | Systems Cluster | SOCS
45 of 59
2/20/2024
Weak Entity Type (3/4)
• Notation used in ER diagrams
– Weak entity type and it’s identifying relationship: Surround their boxes and diamonds
with double lines
– Partial key attribute: underlined with a dashed or dotted line
• Weak entity types can also be represented as complex (composite, multivalued)
attributes
– Example: Specify a multivalued attribute ‘Dependents’ for EMPLOYEE, which is a
composite attribute with component attributes Name, Birth_date, Sex, and
Relationship
Christalin Nelson | Systems Cluster | SOCS
46 of 59
2/20/2024
Weak Entity Type (4/4)
• Any number of levels of weak entity types can be defined
– i.e. An owner entity type may itself be a weak entity type
• A weak entity type may have >1 identifying entity type
• A weak entity type may have an identifying relationship type of degree >2
Christalin Nelson | Systems Cluster | SOCS
47 of 59
2/20/2024
Refining ER Design for COMPANY Database
• Change attributes that represent relationships into relationship types
• Determine cardinality ratio and participation constraint of each relationship type
Christalin Nelson | Systems Cluster | SOCS
Relation Type Relation between
Cardinality
Ratio
Participation Constraint Attribute
WORKS_FOR DEPARTMENT and EMPLOYEE 1:N
EMPLOYEE total
participation
DEPARTMENT total
participation
Nil
MANAGES EMPLOYEE and DEPARTMENT 1:1
EMPLOYEE partial
participation
DEPARTMENT total
participation
Start_date
CONTROLS DEPARTMENT and PROJECT 1:N
DEPARTMENT partial
partcipation
PROJECT total
participation
Nil
SUPERVISION
EMPLOYEE (supervisor role) and
EMPLOYEE (supervisee role)
1:N
EMPLOYEE (supervisor
role) partial participation
EMPLOYEE (supervisee
role) partial
participation
Nil
WORKS_ON EMPLOYEE and PROJECT M:N
EMPLOYEE total
participation
PROJECT total
participation
Hours
DEPENDENTS_OF EMPLOYEE and DEPENDENT 1:N
EMPLOYEE partial
participation
DEPENDENT total
participation
Nil
48 of 59
2/20/2024
Proper naming of Schema Constructs
• Choose names that convey meanings attached to different constructs in the
schema
• Entity types: Singular names rather than plural ones
• Entity type names: Nouns, uppercase letters
• Attribute names: Nouns, Initial letter is capitalized
• Role names: lowercase letters
• Relationship type names: Verbs, uppercase letters
– Choose binary relationship names to make the ER diagram readable from left to right
and from top to bottom
• This issue arises because each binary relationship can be described starting from either of
the two participating entity types
Christalin Nelson | Systems Cluster | SOCS
49 of 59
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
Identifying
50 of 59
2/20/2024
Alternative Notations for ER Diagrams (1/2)
• Specify structural constraints on relationships
– Replace cardinality ratio and participation constraints. Associate a pair of integer
numbers (min, max) with each participation of an entity type E in a relationship type
R, where 0 ≤ min ≤ max and max ≥ 1
– Note: For Participation constraints
• Partial participation (min = 0)
• Total participation (min > 0)
Christalin Nelson | Systems Cluster | SOCS
51 of 59
52
2/20/2024
Christalin Nelson | Systems Cluster | SOCS
52 of 59
2/20/2024
Choosing between Binary & Higher-Degree Relationships (1/5)
• A relationship type(R) of degree(n) will have n edges in an ER diagram, one
connecting R to each participating entity type
Christalin Nelson | Systems Cluster | SOCS
53 of 59
2/20/2024
Choosing between Binary & Higher-Degree Relationships (2/5)
• Three binary relationships cannot replace a ternary relationship, they may do so
under certain additional constraints
– Example: Existence of three relationship instances (s, p), ( j, p), and (s, j) in
CAN_SUPPLY, USES, and SUPPLIES, respectively, does not necessarily imply that an
instance (s, j, p) exists in ternary relationship SUPPLY
Christalin Nelson | Systems Cluster | SOCS
54 of 59
2/20/2024
Choosing between Binary & Higher-Degree Relationships (3/5)
• Some database design tools permit only binary relationships
– Ternary relationships are represented as weak entity types with no partial key and
with three identifying relationships
• Example: The weak entity type SUPPLY is identified by a combination of its three owner
entities from SUPPLIER, PART, and PROJECT
Christalin Nelson | Systems Cluster | SOCS
55 of 59
2/20/2024
Choosing between Binary & Higher-Degree Relationships (4/5)
• A weak entity type with a ternary (or n-ary) identifying relationship type
– The weak entity type can have a partial key and several owner entity types
Christalin Nelson | Systems Cluster | SOCS
56 of 59
2/20/2024
Choosing between Binary & Higher-Degree Relationships (5/5)
• Represent ternary relationship as a regular entity type by introducing an artificial
or surrogate key
– Example: Ternary relationship SUPPLY is converted to a regular entity type by using
artificial Key attribute Supply_id. Three binary N:1 relationships relate SUPPLY to the
three participating entity types.
Christalin Nelson | Systems Cluster | SOCS
57 of 59
2/20/2024
Constraints on Ternary (or Higher-Degree) Relationships
• Two Notations to be used for fully specifying structural constraints on higher-degree
relationships
– First notation is based on the cardinality ratio notation of binary relationships
• If among the three cardinalities, one participation has cardinality specified as 1, then the key
will be the combination of the other two participants
– Example: Relationship set of SUPPLY is a set of relationship instances (s, j, p), where s - SUPPLIER, j -
PROJECT, and p - PART. Suppose that the constraint exists that for a particular project-part
combination only one supplier will be used, then, any relationship instance (s, j, p) is uniquely
identified in relationship set by its (j, p) combination, which makes (j, p) a key for the relationship set
• If all three cardinalities are M or N, then the key will be the combination of all three participants
– Second notation is based on (min, max) notation for binary relationships
• This constraint have no bearing on determining the key of a higher-degree relationship
• Specifies a constraint that places restrictions on how many relationship instances each entity
can participate in
Christalin Nelson | Systems Cluster | SOCS
58 of 59
2/20/2024 Christalin Nelson | Systems Cluster | SOCS 59

More Related Content

What's hot

in-memory database system and low latency
in-memory database system and low latencyin-memory database system and low latency
in-memory database system and low latency
hyeongchae lee
 

What's hot (20)

Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Database overview
Database overviewDatabase overview
Database overview
 
Sql commands
Sql commandsSql commands
Sql commands
 
Storage system architecture
Storage system architectureStorage system architecture
Storage system architecture
 
In-memory Databases
In-memory DatabasesIn-memory Databases
In-memory Databases
 
Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2
 
Storage overview
Storage overviewStorage overview
Storage overview
 
GDPS and System Complex
GDPS and System ComplexGDPS and System Complex
GDPS and System Complex
 
Flex Your Database on 12c's Flex ASM and Flex Cluster
Flex Your Database on 12c's Flex ASM and Flex ClusterFlex Your Database on 12c's Flex ASM and Flex Cluster
Flex Your Database on 12c's Flex ASM and Flex Cluster
 
ORDBMS
ORDBMSORDBMS
ORDBMS
 
Ibm spectrum scale fundamentals workshop for americas part 4 spectrum scale_r...
Ibm spectrum scale fundamentals workshop for americas part 4 spectrum scale_r...Ibm spectrum scale fundamentals workshop for americas part 4 spectrum scale_r...
Ibm spectrum scale fundamentals workshop for americas part 4 spectrum scale_r...
 
Oracle archi ppt
Oracle archi pptOracle archi ppt
Oracle archi ppt
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
 
DB2 and storage management
DB2 and storage managementDB2 and storage management
DB2 and storage management
 
Basic VSAM
Basic VSAMBasic VSAM
Basic VSAM
 
in-memory database system and low latency
in-memory database system and low latencyin-memory database system and low latency
in-memory database system and low latency
 
IBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration BasicsIBM DB2 for z/OS Administration Basics
IBM DB2 for z/OS Administration Basics
 
Rman Presentation
Rman PresentationRman Presentation
Rman Presentation
 
Assignment#11
Assignment#11Assignment#11
Assignment#11
 
IBM Spectrum Scale Overview november 2015
IBM Spectrum Scale Overview november 2015IBM Spectrum Scale Overview november 2015
IBM Spectrum Scale Overview november 2015
 

Similar to Data Modeling - Entity Relationship Diagrams-1.pdf

Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptx
NurulIzrin
 
Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02
Jotham Gadot
 

Similar to Data Modeling - Entity Relationship Diagrams-1.pdf (20)

Week 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptxWeek 2 - Database System Development Lifecycle-old.pptx
Week 2 - Database System Development Lifecycle-old.pptx
 
Unit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptxUnit 2_DBMS_10.2.22.pptx
Unit 2_DBMS_10.2.22.pptx
 
database management system
database management systemdatabase management system
database management system
 
ASMUG February 2015 Knowledge Event
ASMUG February 2015 Knowledge EventASMUG February 2015 Knowledge Event
ASMUG February 2015 Knowledge Event
 
Chapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and ArchitectureChapter-2 Database System Concepts and Architecture
Chapter-2 Database System Concepts and Architecture
 
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptxChapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
Chapter-3-Lesson 1 DM/ Data-Models.ppt/pptx
 
DBMS data modeling.pptx
DBMS data modeling.pptxDBMS data modeling.pptx
DBMS data modeling.pptx
 
Analysis
AnalysisAnalysis
Analysis
 
Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02Fundamentals of Database ppt ch02
Fundamentals of Database ppt ch02
 
Ch1.2_DB system Concepts and Architecture.pptx
Ch1.2_DB system Concepts and Architecture.pptxCh1.2_DB system Concepts and Architecture.pptx
Ch1.2_DB system Concepts and Architecture.pptx
 
Se ii unit3-architectural-design
Se ii unit3-architectural-designSe ii unit3-architectural-design
Se ii unit3-architectural-design
 
DBMS
DBMS DBMS
DBMS
 
(Dbms) class 1 & 2 (Presentation)
(Dbms) class 1 & 2 (Presentation)(Dbms) class 1 & 2 (Presentation)
(Dbms) class 1 & 2 (Presentation)
 
Data models
Data modelsData models
Data models
 
Enterprise Software Development Patterns
Enterprise Software Development PatternsEnterprise Software Development Patterns
Enterprise Software Development Patterns
 
Diksha sda presentation
Diksha sda presentationDiksha sda presentation
Diksha sda presentation
 
architectural design
 architectural design architectural design
architectural design
 
SysCon 2013 SysML & Requirements
SysCon 2013 SysML & RequirementsSysCon 2013 SysML & Requirements
SysCon 2013 SysML & Requirements
 
Dbms unit 1
Dbms unit 1Dbms unit 1
Dbms unit 1
 
Soft requirement
Soft requirementSoft requirement
Soft requirement
 

More from Christalin Nelson

More from Christalin Nelson (16)

Packages and Subpackages in Java
Packages and Subpackages in JavaPackages and Subpackages in Java
Packages and Subpackages in Java
 
Bitwise complement operator
Bitwise complement operatorBitwise complement operator
Bitwise complement operator
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Process Management
Process ManagementProcess Management
Process Management
 
Applications of Stack
Applications of StackApplications of Stack
Applications of Stack
 
Data Storage and Information Management
Data Storage and Information ManagementData Storage and Information Management
Data Storage and Information Management
 
Application Middleware Overview
Application Middleware OverviewApplication Middleware Overview
Application Middleware Overview
 
Network security
Network securityNetwork security
Network security
 
Directory services
Directory servicesDirectory services
Directory services
 
System overview
System overviewSystem overview
System overview
 
Computer Fundamentals-2
Computer Fundamentals-2Computer Fundamentals-2
Computer Fundamentals-2
 
Computer Fundamentals - 1
Computer Fundamentals - 1Computer Fundamentals - 1
Computer Fundamentals - 1
 
Advanced data structures vol. 1
Advanced data structures   vol. 1Advanced data structures   vol. 1
Advanced data structures vol. 1
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Data Modeling - Entity Relationship Diagrams-1.pdf

  • 1.
  • 2. Data Modeling (Part – 1) Presented by: Mr. S. Christalin Nelson 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 2
  • 3. At a Glance • Terminologies & Constraints • Using High-Level Conceptual Data Models for Database Design • Sample Database Application • Entity Types, Entity Sets, Attributes, Keys, and Value Sets • Relationship Types, Relationship Sets, Roles, and Structural Constraints • Weak Entity Types • Refining ER Design for COMPANY Database • ER Diagrams, Naming Conventions, and Design Issues • Relationship Types of Degrees Higher than Two 3 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 3 of 59
  • 4. 2/20/2024 Few Terminologies (1/2) • Domain – Consists of Name, Data type, Format – Set of atomic values • Several Attributes can have the same domain – Example: Domain named "Phone number" can have attributes home_phone, office_phone, mob_phone • Relation – Table name • Relation Schema (or) Relation Intension – Includes Table Name, List of Attributes • Relation State (or) Relation Extension • Relation instance – Single row (or) tuple Christalin Nelson | Systems Cluster | SOCS 4 of 59
  • 5. 2/20/2024 Few Terminologies (2/2) • Degree or Arity – No. of Attributes • Tuples are considered as facts about a relation (or) values satisfying the predicate • Relations represent – Facts about entities – Facts about relationships • Tuple Ordering • Attribute Ordering • Basic Relational model – Composite and Multivalued attributes are not allowed – Also called a flat relational model Christalin Nelson | Systems Cluster | SOCS 5 of 59
  • 6. 2/20/2024 Types of Constraints (1/6) • Inherent model based constraints or Implicit constraints – Example: • A relation cannot have duplicate tuples • Schema-based constraints or Explicit constraints – Example: • Domain constraints • Constraints on NULLs • Key constraints • Entity Integrity constraints • Referential integrity constraints Christalin Nelson | Systems Cluster | SOCS 6 of 59
  • 7. 2/20/2024 Types of Constraints (2/6) • Application-based or semantic constraints or business rules – Specified and enforced on a relational database or by using general-purpose constraint specification language – Example • The salary of an employee should not exceed salary of employee’s supervisor at DB update – Mechanisms: Triggers, Assertions • Data Dependencies – Example: • Functional and Multivalued dependencies – Used with Normalization Christalin Nelson | Systems Cluster | SOCS 7 of 59
  • 8. 2/20/2024 Types of Constraints (3/6) • State constraints (or) Static constraints – Constraints discussed so far – Define the constraints that a valid state of DB must satisfy • Transition constraints (or) Dynamic constraints – Enforced by application programs or specified using active rules and triggers – Example: • Salary of an employee can only increase Christalin Nelson | Systems Cluster | SOCS 8 of 59
  • 9. 2/20/2024 Types of Constraints (4/6) • Domain Constraint – The value of each attribute must be an atomic value • Meanings for NULL values – (1) Not Applicable • E.g. Person with no college degree would have “null” for “College_degrees” attribute – (2) Unknown value – Value exists but is missing or unavailable • E.g. Height attribute of a person – (3) Unknown value – Does not know if value exists • E.g Home_phone attribute of a person Christalin Nelson | Systems Cluster | SOCS 9 of 59
  • 10. 2/20/2024 Types of Constraints (5/6) • Key constraints – Specified on individual relations – Every table has at least one “Superkey” (subset of attributes) – “Superkey” can have redundant attributes – “Key” cannot have redundant attributes – Any “Superkey” formed from a single attribute is also a “Key” – Rules • (1) “Superkey” & “Key” for each tuple should be distinct => “Unique” constraint • (2) “Key” is a “minimal superkey” – i.e. Removal of an attribute will compromise “Unique” constraint – A relation schema may have more than one “key” => termed as “Candidate key” • One candidate is identified as “Primary key” Christalin Nelson | Systems Cluster | SOCS 10 of 59
  • 11. 2/20/2024 Types of Constraints (6/6) • Entity Integrity constraint – Specified on individual relations – No “Primary key” value can be NULL • Referential integrity constraints – Specified between two relations – “Foreign key” in a dependent relation – Rules • (1) Attributes of FK should have the same domain as of PK • (2) Value of FK = value of PK (or) null – FK can refer to another tuple in its own relation Christalin Nelson | Systems Cluster | SOCS 11 of 59
  • 12. 2/20/2024 Data Modeling using ER Model • Data Application – Database, Application program that implements DB Queries and updates – DB design + Software Engineering (Design, Implementation, Testing of Appln.) • Entity-Relationship (ER) model – Popular high-level conceptual data model – ER diagrams • Diagrammatic notation associated with the ER model • Enhanced-ER (EER) model – Includes concepts such as specialization, generalization, inheritance, and union types (categories) • Unified Modeling Language (UML) – Object modeling Christalin Nelson | Systems Cluster | SOCS 12 of 59
  • 13. 2/20/2024 Using High-Level Conceptual Data Models (1/4) • Requirements collection and analysis – DB designers interview prospective DB users to understand and document data requirements & functional requirements • Result-1: Concise set of users’ requirements specified in a detailed and complete form • Result-2: User-defined operations/transactions applied to the DB – Note: • Techniques used to specify functional requirements in Software design include DFD, Sequence diagrams, scenarios • Functional Analysis – Identify high-level user queries and operations Christalin Nelson | Systems Cluster | SOCS 13 of 59
  • 14. Main phases of database design 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 14 of 46 14 of 59
  • 15. 2/20/2024 Using High-Level Conceptual Data Models (3/4) • Conceptual design – Includes • Concise description of Data requirements • Detailed descriptions of entity types, relationships, and constraints • Use the basic data model operations to specify high-level user queries and operations • Note: Does not include implementation details – Result: Conceptual schema of high-level data model – Used to communicate with non-technical users – Used as a reference to ensure that all users’ data requirements are met and do not conflict Christalin Nelson | Systems Cluster | SOCS 15 of 59
  • 16. 2/20/2024 Using High-Level Conceptual Data Models (4/4) • Logical design (or) data model mapping – Transform Conceptual schema from High-level data model into Implementation data model • Actual implementation of DB using a commercial DBMS with an implementation data model (like Relational or Object-relational DB model) – Result: DB schema (Conceptual/Logical Schema in the data model of a specific DBMS) – Often automated or semi-automated within the DB design tools • Physical design phase – Internal storage structures, file organizations, indexes, access paths, and physical design parameters for the database files are specified Result: Internal schema • Application program development Christalin Nelson | Systems Cluster | SOCS 16 of 59
  • 17. 2/20/2024 Sample Database Application • COMPANY Database – Description – Employee • Each employee has a name, social security number, address, salary, sex (gender), and birth date • Each employee works for one department and can work on several projects that other departments can control – Track the current no. of hours per week that an employee works on each project • Track the direct supervisor of each employee (who is another employee) • A particular employee manages the department – Track the start date when an employee began managing the department – Department • Each department has a unique name, a unique number and may have several locations • Can control several projects – Project • Each project has a unique name, a unique number, and a single location – Dependents • Each dependent has a first name, sex (gender), birth date, and relationship to the employee. • Track the dependents of each employee for insurance purposes Christalin Nelson | Systems Cluster | SOCS 17 of 59
  • 18. 18 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 18 of 59
  • 19. 2/20/2024 Entities and their Attributes (1/5) • ER model describes data as Entities, Relationships, and Attributes • Entities – Things in the real world with independent existence • Attributes – Properties that describe an entity – Types • Composite vs. Simple (atomic) attributes • Single-valued vs. Multi-valued attributes • Stored vs. Derived attributes • NULL values (Not Applicable & Unknown) • Complex attributes Christalin Nelson | Systems Cluster | SOCS 19 of 59
  • 20. 2/20/2024 Entities and their Attributes (2/5) • Composite vs. Simple (atomic) attributes – Attributes that are not divisible are called simple (or) atomic attributes – Composite attributes are divided into smaller subparts (basic attributes) • Useful to model situations in which a user sometimes refers to composite attribute as a unit but at other times refers specifically to its components • Value of composite attribute = Concatenation of values of its component simple attributes – Components of a composite attribute are given within parentheses () & separated with commas » Example: Address (Street_address(Number, Street, Apartment_number), City, State, Zip) • Can form a hierarchy (Pic) Christalin Nelson | Systems Cluster | SOCS 20 of 59
  • 21. 2/20/2024 Entities and their Attributes (3/5) • Single-valued vs. Multi-valued attributes – Singled-valued attributes have a single value for a particular entity • Example: “Age” is a single-valued attribute of a person – Multi-valued attributes have a set of values for the same entity • May have lower & upper bounds to constrain the number of values allowed for each entity • Multivalued attributes are mentioned using braces {} – Example: “color” attribute for a car is {blue, red} Christalin Nelson | Systems Cluster | SOCS 21 of 59
  • 22. 2/20/2024 Entities and their Attributes (4/5) • Stored vs. Derived attributes – Values of Stored attributes are given by the user and stored – Values of Derived attributes should be derived • Derived from the related attributes of an entity – Example: “Age” and “Birth_date” attributes of a person » Age attribute (Derived attribute), Birth_date attribute (Stored attribute) • Derived from related entities – Example: Attribute “Number_of_employees” of a DEPARTMENT entity can be derived by counting the number of employees working for that department Christalin Nelson | Systems Cluster | SOCS 22 of 59
  • 23. 2/20/2024 Entities and their Attributes (5/5) • Complex attributes – Composite and multivalued attributes can be nested arbitrarily – Example: Attribute “Address_phone” of a person who can have >1 residence, and each residence can have a single address and multiple phones { Address_phone ( {Phone(Area_code, Phone_number)}, Address(Street_address(Number, Street, Apartment_number), City, State, Zip) ) } Note: Here “Address” and “Phone” are composite attributes Christalin Nelson | Systems Cluster | SOCS 23 of 59
  • 24. 2/20/2024 Entity Types, Entity Sets, Keys, and Value Sets (1/4) • Entity type – Collection (or set) of entities that have the same attributes – Describes Schema (Intension) for the set of entities Christalin Nelson | Systems Cluster | SOCS 24 of 59
  • 25. 2/20/2024 Entity Types, Entity Sets, Keys, and Value Sets (2/4) • Key attribute – Table has one/more attributes whose values are distinct for each entity in entity set • Some entity types have >1 key attribute • Composite Key Attribute: Combination of attribute values must be distinct for each entity – Satisfies the key or uniqueness constraint – Note: • There is no concept of a primary key in the ER model • The primary key will be chosen during mapping to a relational schema (Relational Model) • Weak Entity Type – An entity type without even one key attribute Christalin Nelson | Systems Cluster | SOCS 25 of 59
  • 26. Entity type Rectangular box enclosing the entity type name Attribute names Enclosed in ovals & are attached to their entity type by straight lines Composite attributes Attached to their component attributes by straight lines Multivalued attributes Displayed in double ovals Key attribute Its name underlined inside the oval 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 26 of 59
  • 27. 2/20/2024 Entity Types, Entity Sets, Keys, and Value Sets (4/4) • Value sets (or domain of values) of Attributes – Set of values that may be assigned to that attribute for each entity – Note: • Value sets are not displayed in ER diagrams • Specified using the basic data types available in most programming languages – An attribute (A) of entity set (E) whose value set is V can be defined as a function from E to the power set P(V) of V • A : E → P(V) – Value of attribute(A) for entity (e) is A(e) • NULL value is represented by empty set • For single-valued attributes, A(e) is restricted to a singleton set for each entity(e) in E • There is no restriction on multivalued attributes • For a composite attribute (A), the value set V is the power set of the Cartesian product of P(V1), P(V2), ..., P(Vn), where V1, V2, ..., Vn are the value sets of the simple component attributes that form A: – V = P (P(V1) × P(V2) × ... × P(Vn)) Christalin Nelson | Systems Cluster | SOCS 27 of 59
  • 28. 2/20/2024 Sample Database Application • COMPANY Database – Description – Employee • Each employee has a name, social security number, address, salary, sex (gender), and birth date • Each employee works for one department and can work on several projects that other departments can control – Track the current no. of hours per week that an employee works on each project • Track the direct supervisor of each employee (who is another employee) • A particular employee manages the department – Track the start date when an employee began managing the department – Department • Each department has a unique name, a unique number and may have several locations • Can control several projects – Project • Each project has a unique name, a unique number, and a single location – Dependents • Each dependent has a first name, sex (gender), birth date, and relationship to the employee. • Track the dependents of each employee for insurance purposes Christalin Nelson | Systems Cluster | SOCS 28 of 59
  • 29. 2/20/2024 Initial Conceptual Design of COMPANY Database Christalin Nelson | Systems Cluster | SOCS 29 of 59
  • 30. 2/20/2024 Relationship Types, Relationship Sets (1/3) • Relationship – An attribute of one entity type refers to another entity type – represent references as relationships, and not as attributes • Relationship Types – As with Entity types & Entity sets, a Relationship type and its corresponding Relationship set are referred to by the same name, R • A relationship type(R) among ‘n’ entity types E1, E2, ..., En defines a set of associations (or) a relationship set among entities from these entity types • Each relationship instance (ri) in R is an association of entities, where the association includes exactly one entity from each participating entity type – Each of the entity types E1, E 2, ..., En is said to participate in the relationship type R; similarly, each of the individual entities e1, e2, ..., en is said to participate in the relationship instance ri = (e1, e2, ..., en). Christalin Nelson | Systems Cluster | SOCS 30 of 59
  • 31. 2/20/2024 Relationship Types, Relationship Sets (2/3) • Example: – Consider a relationship type WORKS_FOR between two entity types EMPLOYEE and DEPARTMENT, which associates each employee with the department for which the employee works in the corresponding entity set • Each relationship instance in the relationship set WORKS_FOR associates one EMPLOYEE entity and one DEPARTMENT entity Christalin Nelson | Systems Cluster | SOCS 31 of 59
  • 32. 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 32 of 59
  • 33. 2/20/2024 Relationship Degree • Degree of a relationship type – Number of participating entity types – Examples • WORKS_FOR relationship is of degree two (Binary) • SUPPLY relationship is of degree three (Ternary) Christalin Nelson | Systems Cluster | SOCS 33 of 59
  • 34. 2/20/2024 Relationship as Attributes • Binary relationship type can be thought of in terms of attributes – Consider WORKS_FOR relationship type • The attribute called ‘Department’ of EMPLOYEE entity type, where the value of ‘Department’ for each EMPLOYEE entity is a reference to the DEPARTMENT entity for which that employee works. – The concept of representing relationship types as attributes is used in a class of data models called functional data models • In object DBs, relationships can be represented by reference attributes, either in one direction or in both directions as inverses • In relational DBs, “foreign keys” are a type of reference attribute used to represent relationships Christalin Nelson | Systems Cluster | SOCS 34 of 59
  • 35. 2/20/2024 Role Names and Recursive Relationships (1/2) • Role names – Role name signifies role that a participating entity plays in each relationship instance – Example: • In WORKS_FOR relationship type, EMPLOYEE plays the role of employee/worker and DEPARTMENT plays the role of department/employer • Recursive relationships – The same entity type participates in >1 relationship types in different roles – The role name should be specified – Example: • SUPERVISION relationship type relates an employee to a supervisor, where both employee and supervisor entities are members of the same EMPLOYEE entity set. Here EMPLOYEE entity type participates twice in SUPERVISION in the role of supervisor & role of supervisee Christalin Nelson | Systems Cluster | SOCS 35 of 59
  • 36. 36 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 36 of 59
  • 37. 2/20/2024 Binary Relationship Constraints (1/5) • The constraints limit the possible combinations of entities that may participate in the corresponding relationship set • Types – Cardinality ratio – Participation constraint • Cardinality ratio – Specifies the maximum no. of relationship instances that the entity can participate in – Possible cardinality ratios for binary relationship types are 1:1, 1:N, N:1, and M:N – Example: WORKS_FOR binary relationship type, DEPARTMENT:EMPLOYEE is of cardinality ratio 1:N • Each department can be related to (employs) any number of employees, but an employee can be related to (work for) only one department Christalin Nelson | Systems Cluster | SOCS 37 of 59
  • 38. 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 38 of 59
  • 39. 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 39 of 59
  • 40. 2/20/2024 Binary Relationship Constraints (4/5) • Participation constraint – Specifies whether the existence of an entity depends on it being related to another entity via relationship type – Specifies the minimum no. of relationship instances that each entity can participate in (sometimes called minimum cardinality constraint) – Types: Total & Partial • Examples: – A company policy states that “every employee must work for a department”. An employee entity can exist only if it participates in at least one WORKS_FOR relationship instance. This is called Total Participation (or) Existence Dependency. – Every employee is not expected to manage a department. The participation of EMPLOYEE in the MANAGES relationship type is Partial Participation. Christalin Nelson | Systems Cluster | SOCS 40 of 59
  • 41. 2/20/2024 Binary Relationship Constraints (5/5) • Structural Constraints – Cardinality ratio and Participation Constraints are together considered as structural constraints of a relationship type • ER Notation – Cardinality ratios: Display 1, M, and N on the diamonds – Total participation: Double line connecting participating entity type to the relationship – Partial participation: Single line • Note: – Either specify no minimum (partial participation) or a minimum of one (total participation) – Specify a specific minimum number on participation in the relationship, such as 4 or 5 Christalin Nelson | Systems Cluster | SOCS 41 of 59
  • 42. 2/20/2024 Attributes of Relationship Types (1/2) • Relationship types can also have attributes, similar to those of entity types. – Example • ‘Hours’ attribute for the WORK_ON relationship type to track the number of hours per week that an employee works on a particular project • ‘Start_date’ attribute for the MANAGES relationship type to track the date on which a manager started managing a department via an attribute Christalin Nelson | Systems Cluster | SOCS 42 of 59
  • 43. 2/20/2024 Attributes of Relationship Types (2/2) • Migration of Attribute of Relation Type => Attribute of Entity Type – Attributes of 1:1 relationship types => can be migrated to any one entity type • Example: ‘Start_date’ attribute for MANAGES relationship can be an attribute of either EMPLOYEE or DEPARTMENT, although conceptually it belongs to MANAGES – Attributes of 1:N relationship types => can be migrated only to entity type on the N- side of the relationship • Example: If WORKS_FOR relationship has an attribute ‘Start_date’ that indicates when an employee started working for a department, this attribute can be included as an attribute of EMPLOYEE – For M:N relationship types => No Migration • Example: The value of ‘Hours’ attribute of the M:N relationship WORKS_ON is determined by an employee-project combination and not separately by either entity Christalin Nelson | Systems Cluster | SOCS 43 of 59
  • 44. 2/20/2024 Weak Entity Type (1/4) • Entity Type that do not have key attributes of their own – vs. Strong Entity Type • Identifying relationship – Relates weak entity type (Child or subordinate entity type) to Owner (Parent or Dominant) entity type • Entities of a weak entity type are identified by being related to specific entities from owner – Always has a total participation constraint or existence dependency • Note: Not every existence dependency results in a weak entity type – Example: DRIVER_LICENSE entity cannot exist unless it is related to a PERSON entity, even though it has its own key (License_number). Hence is not a weak entity. Christalin Nelson | Systems Cluster | SOCS 44 of 59
  • 45. 2/20/2024 Weak Entity Type (2/4) • Example – Entity type DEPENDENT is related to EMPLOYEE via a 1:N relationship. Each employee entity is said to OWN the dependent entities that are related to it. • Note: Two dependents of two distinct employees may, by chance, have the same values for Name, Birth_date, Sex, and Relationship, but they are still distinct entities. They are identified as distinct entities ONLY after determining the employee entity to which each dependent is related. • Partial key or Discriminator – Attribute that uniquely identifies weak entities that are related to same owner entity – Example: The attribute ‘Name’ of DEPENDENT is the partial key Christalin Nelson | Systems Cluster | SOCS 45 of 59
  • 46. 2/20/2024 Weak Entity Type (3/4) • Notation used in ER diagrams – Weak entity type and it’s identifying relationship: Surround their boxes and diamonds with double lines – Partial key attribute: underlined with a dashed or dotted line • Weak entity types can also be represented as complex (composite, multivalued) attributes – Example: Specify a multivalued attribute ‘Dependents’ for EMPLOYEE, which is a composite attribute with component attributes Name, Birth_date, Sex, and Relationship Christalin Nelson | Systems Cluster | SOCS 46 of 59
  • 47. 2/20/2024 Weak Entity Type (4/4) • Any number of levels of weak entity types can be defined – i.e. An owner entity type may itself be a weak entity type • A weak entity type may have >1 identifying entity type • A weak entity type may have an identifying relationship type of degree >2 Christalin Nelson | Systems Cluster | SOCS 47 of 59
  • 48. 2/20/2024 Refining ER Design for COMPANY Database • Change attributes that represent relationships into relationship types • Determine cardinality ratio and participation constraint of each relationship type Christalin Nelson | Systems Cluster | SOCS Relation Type Relation between Cardinality Ratio Participation Constraint Attribute WORKS_FOR DEPARTMENT and EMPLOYEE 1:N EMPLOYEE total participation DEPARTMENT total participation Nil MANAGES EMPLOYEE and DEPARTMENT 1:1 EMPLOYEE partial participation DEPARTMENT total participation Start_date CONTROLS DEPARTMENT and PROJECT 1:N DEPARTMENT partial partcipation PROJECT total participation Nil SUPERVISION EMPLOYEE (supervisor role) and EMPLOYEE (supervisee role) 1:N EMPLOYEE (supervisor role) partial participation EMPLOYEE (supervisee role) partial participation Nil WORKS_ON EMPLOYEE and PROJECT M:N EMPLOYEE total participation PROJECT total participation Hours DEPENDENTS_OF EMPLOYEE and DEPENDENT 1:N EMPLOYEE partial participation DEPENDENT total participation Nil 48 of 59
  • 49. 2/20/2024 Proper naming of Schema Constructs • Choose names that convey meanings attached to different constructs in the schema • Entity types: Singular names rather than plural ones • Entity type names: Nouns, uppercase letters • Attribute names: Nouns, Initial letter is capitalized • Role names: lowercase letters • Relationship type names: Verbs, uppercase letters – Choose binary relationship names to make the ER diagram readable from left to right and from top to bottom • This issue arises because each binary relationship can be described starting from either of the two participating entity types Christalin Nelson | Systems Cluster | SOCS 49 of 59
  • 50. 2/20/2024 Christalin Nelson | Systems Cluster | SOCS Identifying 50 of 59
  • 51. 2/20/2024 Alternative Notations for ER Diagrams (1/2) • Specify structural constraints on relationships – Replace cardinality ratio and participation constraints. Associate a pair of integer numbers (min, max) with each participation of an entity type E in a relationship type R, where 0 ≤ min ≤ max and max ≥ 1 – Note: For Participation constraints • Partial participation (min = 0) • Total participation (min > 0) Christalin Nelson | Systems Cluster | SOCS 51 of 59
  • 52. 52 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 52 of 59
  • 53. 2/20/2024 Choosing between Binary & Higher-Degree Relationships (1/5) • A relationship type(R) of degree(n) will have n edges in an ER diagram, one connecting R to each participating entity type Christalin Nelson | Systems Cluster | SOCS 53 of 59
  • 54. 2/20/2024 Choosing between Binary & Higher-Degree Relationships (2/5) • Three binary relationships cannot replace a ternary relationship, they may do so under certain additional constraints – Example: Existence of three relationship instances (s, p), ( j, p), and (s, j) in CAN_SUPPLY, USES, and SUPPLIES, respectively, does not necessarily imply that an instance (s, j, p) exists in ternary relationship SUPPLY Christalin Nelson | Systems Cluster | SOCS 54 of 59
  • 55. 2/20/2024 Choosing between Binary & Higher-Degree Relationships (3/5) • Some database design tools permit only binary relationships – Ternary relationships are represented as weak entity types with no partial key and with three identifying relationships • Example: The weak entity type SUPPLY is identified by a combination of its three owner entities from SUPPLIER, PART, and PROJECT Christalin Nelson | Systems Cluster | SOCS 55 of 59
  • 56. 2/20/2024 Choosing between Binary & Higher-Degree Relationships (4/5) • A weak entity type with a ternary (or n-ary) identifying relationship type – The weak entity type can have a partial key and several owner entity types Christalin Nelson | Systems Cluster | SOCS 56 of 59
  • 57. 2/20/2024 Choosing between Binary & Higher-Degree Relationships (5/5) • Represent ternary relationship as a regular entity type by introducing an artificial or surrogate key – Example: Ternary relationship SUPPLY is converted to a regular entity type by using artificial Key attribute Supply_id. Three binary N:1 relationships relate SUPPLY to the three participating entity types. Christalin Nelson | Systems Cluster | SOCS 57 of 59
  • 58. 2/20/2024 Constraints on Ternary (or Higher-Degree) Relationships • Two Notations to be used for fully specifying structural constraints on higher-degree relationships – First notation is based on the cardinality ratio notation of binary relationships • If among the three cardinalities, one participation has cardinality specified as 1, then the key will be the combination of the other two participants – Example: Relationship set of SUPPLY is a set of relationship instances (s, j, p), where s - SUPPLIER, j - PROJECT, and p - PART. Suppose that the constraint exists that for a particular project-part combination only one supplier will be used, then, any relationship instance (s, j, p) is uniquely identified in relationship set by its (j, p) combination, which makes (j, p) a key for the relationship set • If all three cardinalities are M or N, then the key will be the combination of all three participants – Second notation is based on (min, max) notation for binary relationships • This constraint have no bearing on determining the key of a higher-degree relationship • Specifies a constraint that places restrictions on how many relationship instances each entity can participate in Christalin Nelson | Systems Cluster | SOCS 58 of 59
  • 59. 2/20/2024 Christalin Nelson | Systems Cluster | SOCS 59