Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multiplicity in E/R Diagrams

Similar presentations


Presentation on theme: "Multiplicity in E/R Diagrams"— Presentation transcript:

1 Multiplicity in E/R Diagrams
Rule: the head of the arrow can have at most one value, given values to the other entities in the relationship. Product Purchase Store Person

2 Design Principles What’s wrong? Purchase Product Person President
Country Person Moral: be faithful!

3 What’s Wrong? date Product Purchase Store Moral: don’t talk too much.
personAddr person

4 What’s Wrong? date Dates Product Purchase Store Moral: don’t
complicate life more than it already is. Person

5 Do we really need 3-way relationships?
ProductOf Product Purchase StoreOf Store Moral: Find a nice way to say things. BuyerOf Person

6 Modeling Subclasses The world is not flat!
Some objects in a class may have properties not shared by other members: Products Software products Educational products So --- we define subclasses (in ODL and in E/R).

7 Subclasses in ODL Interface SoftwareProduct: Product{
attribute Set<string> platform; attribute Set<integer> requiredMemory; } Interface EducationalProduct: Product{ attribute Struct Interval {integer begin, integer end} ageGroup; attribute string topic The two classes also inherit all the properties of Product.

8 Multiple Inheritance Product Platforms required memory ageGroup topic
Educational Product Software Product Educ-software Product Educational-method

9 How do we resolve conflicts?
Rating (ATA) Product Platforms required memory ageGroup topic Educational Product Software Product Rating (ASA) Educ-software Product Educational-method Rating?

10 Subclasses in E/R Diagrams
name category price Product isa isa Software Product Educational Product platforms Age Group

11 In ODL: Every object belongs to a single class In E/R: An entity may be spread out in multiple sets. name category price Product isa isa Software Product Educational Product platforms Age Group

12 Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely identifies a person. Single-value constraints: a person can have only one father. Referential integrity constraints: if you work for a company, it must exist in the database. Domain constraints: peoples’ ages are between 0 and 150. Why are these constraints useful in the implementation?

13 Keys A set of attributes that uniquely identify an object or entity:
Person: social security number name name + address name + address + age Perfect keys are often hard to find, so organizations usually invent something. An object may have multiple keys: employee number, social-security number

14 Keys in ODL Interface Person (key ssn) { properties… }
Defining multiple keys: (key ssn employeID (name address age))

15 Keys in E/R Diagrams name category price Product No formal way
to specify multiple keys in E/R diagrams Person name ssn address

16 Single Value Constraints
An entity (or object) may have at most one value for a given attribute or relationship. Person: name, social-security number Company: stock price How do we do this in ODL? In E/R, every attribute has at most one value. Arrows tell us about multiplicity of relations. If we have a single-valued constraint, we can either: 1. Require that the value exist (see referential integrity shortly) 2. Allow null values.

17 Referential Integrity Constraints
A relationship has one value and the value must exist. Example: Product madeBy Company: company must exist. How do we enforce referential integrity constraints? (otherwise, we get dangling pointers) - forbid to delete a reference object, or - delete the objects that reference an object we’re deleting. In E/R diagrams: makes Product Company

18 Weak Entity Sets Entity sets are weak when their key attributes come from other classes to which they are related. This happens if: - part-of hierarchies - splitting n-ary relations to binary. affiliation Team University sport number name


Download ppt "Multiplicity in E/R Diagrams"

Similar presentations


Ads by Google