【正文】
rshan Database System Concepts Relationship Sets with Attributes 169。Silberschatz, Korth and Sudarshan Database System Concepts ER Diagrams ? Rectangles represent entity sets. ? Diamonds represent relationship sets. ? Lines link attributes to entity sets and entity sets to relationship sets. ? Ellipses represent attributes ? Double ellipses represent multivalued attributes. ? Dashed ellipses denote derived attributes. ? Underline indicates primary key attributes (will study later) 169。Silberschatz, Korth and Sudarshan Database System Concepts Mapping Cardinalities Many to one Many to many Note: Some elements in A and B may not be mapped to any elements in the other set 169。Silberschatz, Korth and Sudarshan Database System Concepts Mapping Cardinalities ? Express the number of entities to which another entity can be associated via a relationship set. ? Most useful in describing binary relationship sets. ? 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 169。Silberschatz, Korth and Sudarshan Database System Concepts Relationship Sets (Cont.) ? An attribute can also be property of a relationship set. ? For instance, the depositor relationship set between entity sets customer and account may have the attribute accessdate 169。Silberschatz, Korth and Sudarshan Database System Concepts Relationship Sets ? A relationship is an association among several entities Example: Hayes depositor A102 customer entity relationship set account entity ? A relationship set is a mathematical relation among n ? 2 entities, each taken from entity sets {(e1, e2, … en) | e1 ? E1, e2 ? E2, …, en ? En} where (e1, e2, …, en) is a relationship ? Example: (Hayes, A102) ? depositor 169。Silberschatz, Korth and Sudarshan Database System Concepts Attributes ? An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set. ? Domain – the set of permitted values for each attribute ? Attribute types: ? Simple and posite attributes. ? Singlevalued and multivalued attributes ? . multivalued attribute: phonenumbers ? Derived attributes ? Can be puted from other attributes ? . age, given date of birth Example: customer = (customerid, customername, customerstreet, customercity) loan = (loannumber, amount) 169。Silberschatz, Korth and Sudarshan Database System Concepts Entity Sets ? A database can be modeled as: ? a collection of entities, ? relationship among entities. ? An entity is an object that exists and is distinguishable from other objects. ? Example: specific person, pany, event, plant ? Entities have attributes ? Example: people have names and addresses ? An entity set is a set of entities of the same type that share the same properties. ? Example: set of all persons, panies, trees, holidays 169。169。Silberschatz, Korth and Sudarshan Database System Concepts Chapter 2: EntityRelationship Model ? Entity Sets ? Relationship Sets ? Design Issues ? Mapping Constraints ? Keys ? ER Diagram ? Extended ER Features ? Design of an ER Database Schema ? Reduction of an ER Schema to Tables 169。Silberschatz, Korth and Sudarshan Database System Concepts Entity Sets customer and loan customerid customer customer customer loan amount name street city number 169。Silberschatz, Korth and Sudarshan Database System Concepts Composite Attributes 169。Silberschatz, Korth and Sudarshan Database System Concepts Relationship Set borrower 169。Silberschatz, Korth and Sudarshan Database System Concepts Degree of a Relationship Set ? Refers to number of entity sets that participate in a relationship set. ? Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary. ? Relationship sets may involve more than two entity sets. ? Relationships between more than two entity sets are rare. Most relationships are binary. (More on this later.) ?. 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 169。Silberschatz, Korth and Sudarshan Database System Concepts Mapping Cardinalities One to one One to many Note: Some elements in A and B may not be mapped to any elements in the other set 169。Silberschatz, Korth and Sudarshan Database System Concepts Mapping Cardinalities affect ER Design ? Can make accessdate an attribute of account, instead of a relationship attribute, if each account can have only one customer ? ., the relationship from account to customer is many to one, or equivalently, customer to account is one to many 169。Silberschatz, Korth and Sudarshan Database System Concepts ER Diagram With Composite, Multivalued, and Derived Attributes 169。Silberschatz, Korth and Sudarshan Database System Concepts Roles ? Entity sets of a relationship need not be distinct ? The labels ―manager‖ and ―worker‖ are called roles。Silberschatz, Korth and Sudarshan Database System Concepts Cardinality Constraints ? We express cardinality constraints by drawing either a directed line (?), signifying ―one,‖ or an undirected line (—), signifying ―many,‖ between the relationship set and