Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely.

Similar presentations


Presentation on theme: "Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely."— Presentation transcript:

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

2 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, but organizations usually invent something anyway. An object may have multiple keys: employee number, social-security number

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

4 Keys in E/R Diagrams address namessn Person Product namecategory price No formal way to specify multiple keys in E/R diagrams

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

6 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. CompanyProduct makes In E/R diagrams:

7 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. UniversityTeam affiliation numbersportname


Download ppt "Modeling Constraints Extracting constraints is what modeling is all about. But how do we express them? Examples: Keys: social security number uniquely."

Similar presentations


Ads by Google