Sie sind auf Seite 1von 21

Lecture 12

  EER model
  Inheritance
Extended/Enhanced
  EER means extended (or enhanced) entity-
relationship model.
  EER contains the following additional
concepts:
  Classes
  Specialisation
  Categories
  Inheritance
Classes
  There are sub-classes and super-classes.
  An entity can have sub-groupings that you may want to

represent in the schema:


E.g. A motorbike Grand Prix racing Team Member might be
sub-grouped into Rider, Mechanic, Support or Manager
(based on job).
Or Team Member might be sub-grouped into Full-time, Part-
time (based on contract).

EER diagrams extend ER


Diagrams to include these
sub-groupings
Subtypes
  Subtypes are joined by lines with a hook.
EER diagram
  The same hook symbol is used
  But they are joined via a circle
  This example: partial participation (it may be an orange)
  This example: disjoint sub-classes (it cannot be an apple
and a pear)
EER diagram
  This is equivalent to Java abstract classes
  A double-line indicates total participation
  This example: total participation (it has to be red or white or
rose)
  This example: disjoint sub-classes (it cannot be an apple
and a pear)
Classes
  An entity that is a member of a sub-class is
the same entity in the real world as the entity
in the super-class.
  But in a specific role.

  An entity cannot exist

in the database only


as a member of the
sub-class, it must also
be a member of the
super-class.
Distinct/Overlapping/Union
  The letter in the circle can be used to
represent 3 different possibilities
  'd' for distinct (previous examples)
  'o' for overlapping (this example)
  'u' for union of super-classes
Inheritance
  An entity in a sub-class inherits from its
super-class:
All properties
All relationships
Selective Inheritance
  In this case, OWNER inherits properties of
PERSON, BANK or COMPANY.
  Union sub-types can be called categories
Multiple Inheritance
  In this case, an umbrella girl is both a Pit
Worker and a PR representative.
  If the same property is inherited from both
super-classes, it only appears once. E.g.
Salary.
Specialisation
  Specialisation is the name given to the
process of maximising the differences
between members of an entity by identifying
their distinguishing characteristics
  A specialisation lattice is what you get when
your EER diagram no longer looks like a
simple tree
Specialization / Generalization
Lattice Example (UNIVERSITY)
Generalisation
  Generalisation is the name given to the
process of suppressing differences between
entities.
  You find entities which share common
properties and group them to form a super-
class.
Racers, umbrella girls, track officials,
press are all on the grid at the start
of a race and share properties like:
time on, time off, penalty, insurance
EER to schema mapping
  There are 4 ways to map an ERR super-type/
sub-type to a database schema. The one you
choose will depend on the data; try to think of
the optimal solution.
  Create one table for each type, all of the sub-types will have
a foreign key to the primary key of the super-type.
  Create one table for each sub-type, every table having the
primary key of the super-type plus all of its attributes.
  Create one table, containing all attributes of all sub-types
and super-type.
  Create one table, as above, but add a column flagging the
sub-type.
EER mapping
  Will demonstrate the 4 ways on this example
EER to schema mapping
  There are 4 ways to map an ERR super-type/
sub-type to a database schema. The one you
choose will depend on the data; try to think of
the optimal solution.
  Create one table for each type, all of the sub-types will have
a foreign key to the primary key of the super-type.
  Create one table for each sub-type, every table having the
primary key of the super-type plus all of its attributes.
  Create one table, containing all attributes of all sub-types
and super-type.
  Create one table, as above, but add a column flagging the
sub-type.
EER mapping
  Create one table (schema) for each type
Chip (ID, print date, designer)
PK: ID

FPA unit (ID, operations)


PK: ID
FK: ID from Chip(ID)

Reg. block (ID, no. registers)


PK: ID
FK: ID from Chip(ID)

L1 cache (ID, memory size)


PK: ID
FK: ID from Chip(ID)
EER mapping
  Create one table (schema) for each sub- type
FPA unit (ID, operations, print date, designer)
PK: ID

Reg. block (ID, no. registers, print date, designer)


PK: ID

L1 cache (ID, memory size, print date, designer)


PK: ID
EER mapping
  Create one table (schema)
Chip (ID, print date, designer, operations, registers, memory
size)
PK: ID
EER mapping
  Create one table (schema)
Chip (ID, print date, designer, chip subtype, operations,
registers, memory size)
PK: ID

Das könnte Ihnen auch gefallen