Entity-relational Data Modeling-Database System Concepts, Slides of Database Management Systems (DBMS)

Entity-relational Data Modelling, E-R Applications, Modelling, Entities, Relationship, Attributes, Properties, Relationship Sets, Degree of a Relationship Set, Binary, Domain, Attribute Types, Simple, composite Attributes, Single-valued, Single-valued, Derived Attributes, Cardinality Constraints, One to One, One to Many, Many to One, Many to Many, Keys, super key, Candidate key, Primary Key, E-R Diagrams, Roles, Cardinality Constraints, Notation, Ternary Relationship, Design Issues, Binary versu

Typology: Slides

2011/2012

Uploaded on 01/31/2012

beatryx
beatryx 🇺🇸

4.6

(16)

289 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Computing & Information Sciences
Kansas State University
Friday, 22 Sep 2006CIS 560: Database System Concepts
Lecture 13 of 42
Friday, 22 September 2006
William H. Hsu
Department of Computing and Information Sciences, KSU
KSOL course page: http://snipurl.com/va60
Course web site: http://www.kddresearch.org/Courses/Fall-2006/CIS560
Instructor home page: http://www.cis.ksu.edu/~bhsu
Reading for Next Class:
Rest of Chapter 6, Silberschatz et al., 5th edition
Entity-Relational Data Modeling
Notes: PS3 Notes, E-R Applications (Projects)
Computing & Information Sciences
Kansas State University
Friday, 22 Sep 2006CIS 560: Database System Concepts
Modeling
Modeling
zA database can be modeled as:
a collection of entities,
relationship among entities.
zAn entity is an object that exists and is distinguishable from
other objects.
Example: specific person, company, event, plant
zEntities have attributes
Example: people have names and addresses
zAn entity set is a set of entities of the same type that share the
same properties.
Example: set of all persons, companies, trees, holidays
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Entity-relational Data Modeling-Database System Concepts and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Lecture 13 of 42

Friday, 22 September 2006

William H. Hsu Department of Computing and Information Sciences, KSU

KSOL course page: http://snipurl.com/va Course web site: http://www.kddresearch.org/Courses/Fall-2006/CIS Instructor home page: http://www.cis.ksu.edu/~bhsu

Reading for Next Class: Rest of Chapter 6, Silberschatz et al. , 5 th^ edition

Entity-Relational Data Modeling

Notes: PS3 Notes, E-R Applications (Projects)

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Modeling Modeling

z A database can be modeled as: ’ a collection of entities, ’ relationship among entities. z An entity is an object that exists and is distinguishable from other objects. ’ Example: specific person, company, event, plant z Entities have attributes ’ Example: people have names and addresses z An entity set is a set of entities of the same type that share the same properties. ’ Example: set of all persons, companies, trees, holidays

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Entity SetsEntity Sets^ customercustomer^ andand loanloan

customer_id customer_ customer_ customer_ loan_ amount name street city number

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Relationship Sets Relationship Sets

z A relationship is an association among several entities Example: Hayes depositor A- customer entity relationship set account entity z A relationship set is a mathematical relation among n ≥ 2 entities, each taken from entity sets {( e 1 , e 2 , … e (^) n ) | e 1 ∈ E 1 , e 2 ∈ E 2 , …, e (^) nEn }

where ( e 1 , e 2 , …, e (^) n ) is a relationship ’ Example: (Hayes, A-102) ∈ depositor

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Degree of a Relationship Set Degree of a Relationship Set

z Refers to number of entity sets that participate in a relationship set. z Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary. z Relationship sets may involve more than two entity sets.

z Relationships between more than two entity sets are rare. Most relationships are binary. (More on this later.)

Example: Suppose employees of a bank may have jobs (responsibilities) at multiple branches, with different jobs at different branches. Then there is a ternary relationship set between entity sets employee, job, and branch

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Attributes Attributes

z An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set.

z Domain – the set of permitted values for each attribute z Attribute types: ’ Simple and composite attributes. ’ Single-valued and multi-valued attributes Ö Example: multivalued attribute: phone_numbers ’ Derived attributes Ö Can be computed from other attributes Ö Example: age, given date_of_birth

Example: customer = ( customer_id, customer_name, customer_street, customer_city ) loan = ( loan_number, amount )

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Composite Attributes Composite Attributes

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Mapping Cardinality Constraints Mapping Cardinality Constraints

z Express the number of entities to which another entity can be associated via a relationship set. z Most useful in describing binary relationship sets. z For a binary relationship set the mapping cardinality must be one of the following types: ’ One to one ’ One to many ’ Many to one ’ Many to many

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Keys Keys

z A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity. z A candidate key of an entity set is a minimal super key ’ Customer_id is candidate key of customer ’ account_number is candidate key of account z Although several candidate keys may exist, one of the candidate keys is selected to be the primary key.

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Keys for Relationship Sets Keys for Relationship Sets

z The combination of primary keys of the participating entity sets forms a super key of a relationship set. ’ ( customer_id, account_number ) is the super key of depositor ’ NOTE: this means a pair of entity sets can have at most one relationship in a particular relationship set. Ö Example: if we wish to track all access_dates to each account by each customer, we cannot assume a relationship for each access. We can use a multivalued attribute though z Must consider the mapping cardinality of the relationship set when deciding the what are the candidate keys z Need to consider semantics of relationship set in selecting the primary key in case of more than one candidate key

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

E-R DiagramsE-R Diagrams

„ Rectangles represent entity sets. „ Diamonds represent relationship sets. „ Lines link attributes to entity sets and entity sets to relationship sets. „ Ellipses represent attributes z Double ellipses represent multivalued attributes. z Dashed ellipses denote derived attributes. „ Underline indicates primary key attributes (will study later)

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

E-R Diagram With Composite, Multivalued, and Derived Attributes

E-R Diagram With Composite, Multivalued, and Derived Attributes

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Cardinality Constraints Cardinality Constraints

z We express cardinality constraints by drawing either a directed line (→), signifying “one,” or an undirected line (—), signifying “many,” between the relationship set and the entity set. z One-to-one relationship: ’ A customer is associated with at most one loan via the relationship borrower ’ A loan is associated with at most one customer via borrower

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

One-To-Many RelationshipOne-To-Many Relationship

z In the one-to-many relationship a loan is associated with at most one customer via borrower , a customer is associated with several (including 0) loans via borrower

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Many-To-One RelationshipsMany-To-One Relationships

z In a many-to-one relationship a loan is associated with several (including 0) customers via borrower , a customer is associated with at most one loan via borrower

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Many-To-Many Relationship Many-To-Many Relationship

z A customer is associated with several (possibly 0) loans via borrower z A loan is associated with several (possibly 0) customers via borrower

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

E-R E-R Diagram with a Ternary RelationshipDiagram with a Ternary Relationship

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Cardinality Constraints on Ternary

Relationship

Cardinality Constraints on Ternary

Relationship

z We allow at most one arrow out of a ternary (or greater degree) relationship to indicate a cardinality constraint z E.g. an arrow from works_on to job indicates each employee works on at most one job at any branch. z If there is more than one arrow, there are two ways of defining the meaning. ’ E.g a ternary relationship R between A , B and C with arrows to B and C could mean

  1. each A entity is associated with a unique entity from B and C or
  2. each pair of entities from ( A, B ) is associated with a unique C entity, and each pair ( A, C ) is associated with a unique B ’ Each alternative has been used in different formalisms ’ To avoid confusion we outlaw more than one arrow

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Design Issues Design Issues

z Use of entity sets vs. attributes Choice mainly depends on the structure of the enterprise being modeled, and on the semantics associated with the attribute in question. z Use of entity sets vs. relationship sets Possible guideline is to designate a relationship set to describe an action that occurs between entities z Binary versus n-ary relationship sets Although it is possible to replace any nonbinary ( n -ary, for n >

  1. relationship set by a number of distinct binary relationship sets, a n -ary relationship set shows more clearly that several entities participate in a single relationship. z Placement of relationship attributes

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Binary Vs. Non-Binary RelationshipsBinary Vs. Non-Binary Relationships

z Some relationships that appear to be non-binary may be better represented using binary relationships ’ E.g. A ternary relationship parents , relating a child to his/her father and mother, is best replaced by two binary relationships, father and mother Ö Using two binary relationships allows partial information (e.g. only mother being know) ’ But there are some relationships that are naturally non-binary Ö Example: works_on

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Mapping Cardinalities affect ER DesignMapping Cardinalities affect ER Design

„ Can make access-date an attribute of account, instead of a relationship attribute, if each account can have only one customer z That is, the relationship from account to customer is many to one, or equivalently, customer to account is one to many

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

ER Domains: Term Projects for 560 ER Domains: Term Projects for 560

Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University

Weak Entity SetsWeak Entity Sets

z An entity set that does not have a primary key is referred to as a weak entity set. z The existence of a weak entity set depends on the existence of a identifying entity set ’ it must relate to the identifying entity set via a total, one-to-many relationship set from the identifying to the weak entity set ’ Identifying relationship depicted using a double diamond z The discriminator ( or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set. z The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence dependent, plus the weak entity set’s discriminator.