Title: Multiplicity in E/R Diagrams
1Multiplicity 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
2Design Principles
Whats wrong?
Purchase
Product
Person
President
Person
Country
Moral be faithful!
3Whats Wrong?
date
Product
Purchase
Store
Moral dont talk too much.
personAddr
person
4Whats Wrong?
date
Dates
Product
Purchase
Store
Moral dont complicate life more than it
already is.
Person
5Do we really need 3-way relationships?
ProductOf
Product
Purchase
StoreOf
Store
Moral Find a nice way to say things.
BuyerOf
Person
6Modeling 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).
7Subclasses in ODL
Interface SoftwareProduct Product
attribute Setltstringgt platform
attribute Setltintegergt requiredMemory Interf
ace EducationalProduct Product
attribute Struct Interval integer begin, integer
end ageGroup attribute string
topic
The two classes also inherit all the properties
of Product.
8Multiple Inheritance
Product
Platforms required memory
ageGroup topic
Educational Product
Software Product
Educational-method
Educ-software Product
9How do we resolve conflicts?
Rating (ATA)
Product
Platforms required memory
ageGroup topic
Educational Product
Software Product
Rating (ASA)
Educational-method
Educ-software Product
Rating?
10 Subclasses in E/R Diagrams
name
category
price
Product
isa
isa
Educational Product
Software Product
Age Group
platforms
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
Educational Product
Software Product
Age Group
platforms
12Modeling 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?
13Keys
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
14Keys 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
16Single 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.
17Referential 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 were deleting.
In E/R diagrams
makes
Company
Product
18Weak 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
University
Team
number
sport
name