









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 17
This page cannot be seen from the preview
Don't miss anything!










Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University
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
Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University
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
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
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 (^) n ∈ En }
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
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
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
Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University
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
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
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
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
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
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
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
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
Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University
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
Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University
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 >
Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University
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
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
Computing & Information Sciences CIS 560: Database System Concepts Friday, 22 Sep 2006 Kansas State University
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.