Presentation is loading. Please wait.

Presentation is loading. Please wait.

name category name price makes Company Product stockprice buys employs

Similar presentations


Presentation on theme: "name category name price makes Company Product stockprice buys employs"— Presentation transcript:

1 name category name price makes Company Product stockprice buys employs Person name ssn address

2 Multi-way Relationships
How do we model a purchase relationship between buyers, products and stores? Product Purchase Store Person

3 Roles in Relationships
What if we need an entity set twice in one relationship? Product Purchase Store buyer salesperson Person

4 Roles in Relationships
Note the multiplicity of the relationships: we cannot express all possibilities Product Purchase Store buyer salesperson Person

5 Attributes on Relationships
date Product Purchase Store Person

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

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

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

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

10 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).

11 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.

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

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

14 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?

15 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

16 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?

17 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

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

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

20 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.

21 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

22 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 "name category name price makes Company Product stockprice buys employs"

Similar presentations


Ads by Google