Beruflich Dokumente
Kultur Dokumente
Semantic concepts are incorporated into the original ER model and called the
Enhanced Entity-Relationship (EERM) model.
Superclass
An entity type that includes one or more distinct subgroupings of
its occurrences
Subclass
A distinct subgrouping of occurrences of an entity type
EERM - Specialization / Generalization
Attribute Inheritance
An entity in a subclass represents same ‘real world’ object as in
superclass, and may possess subclass-specific attributes, as well
as those associated with the superclass.
EERM - Specialization / Generalization
Specialization
Process of maximizing differences between members of an
entity by identifying their distinguishing characteristics.
Generalization
Process of minimizing differences between entities by
identifying their common characteristics.
EERM - Specialization / Generalization (examples)
Participation constraints
determine whether every member in superclass must be a
member of at least one subclass
a specialization/generalization may be mandatory or optional
Disjoint constraints
describe a relationship between members of the subclasses and
indicates whether a member of a superclass can be a member of
one, or more than one, subclasses
a specialization/generalization may be disjoint or non-disjoint
EERM - Specialization / Generalization (Constraints)
Participation Constraints
mandatory optional
mandatory & optional &
Disjoint disjoint disjoint disjoint
Constr
aints non- mandatory & optional &
disjoint non-disjoint non-disjoint
EERM - Specialization / Generalization (Constraints - Examples)
Faithfulness
A design should be faithful to the specifications of the applications, i.e. it should
reflect reality.
Avoid redundancy
Be careful to say everything once, otherwise you may end up producing a confusing
and inconsistent design.
Simplicity
Avoid introducing more elements into your design than it is absolutely necessary.
Choose the correct relationships
Adding every relationship is not always a good idea. It can lead to redundancy,
storage waste, complex updates, but it can also not represent faithfully users’
perception of relationships (connection traps).
To overcome the problem find out the validity of any assumptions you make and also
the queries that will be asked.
Design Principles
Picking the Right Kind of Element
Sometimes options exist regarding the type of design elements used to
represent reality. In general an attribute is simpler to implement than either an
entity or a relationship. However, making everything an attribute is not wise
either.
In general the following rule can be applied:
Let E be an entity
whose attributes collectively identify the entity, i.e. if E has more than 1 attribute
then no attribute must depend on the other attributes and
that is involved only in one-many relationships with E always in the one side of
the relationship is in the 1-side and
that is not involved in a relationship with another entity more than once
Then E could be removed and its attributes should become (suitably
renamed, if necessary) attributes of each entity it is related to. If E participates
in a multi-way relationship then its attributes should be made attributes of the
multi-way relationship instead.
The Relational Data Model
Relational Model - Instances of Branch and Staff Relations
Relational Model - Examples of Attribute Domains
Relational Model (Terminology)
Relation
(conceptually) a table with columns and rows
Attribute
a named column of a relation
Domain
the set of allowable values for one or more attributes
Tuple
a row of a relation
Degree
the number of attributes in a relation
Cardinality
the number of tuples in a relation
Relational Database
a collection of normalized relations with distinct relation names
Alternative Terminology for Relational Model
Data Redundancy
Relation schema
Named relation defined by a set of attribute and domain name
pairs
Relation name is distinct from all other relation names in relational schema.
Each cell of relation contains exactly one atomic (single) value (1st Normal
Form / 1NF Assumption)
Superkey
An attribute, or a set of attributes, that uniquely identifies a tuple
within a relation.
Candidate Key
Superkey (K) such that no proper subset is a superkey within the
relation.
In each tuple of R, values of K uniquely identify that tuple
(uniqueness).
No proper subset of K has the uniqueness property (irreducibility).
Relational Keys
Primary Key
Candidate key selected to identify tuples uniquely within relation.
Alternate Keys
Candidate keys that are not selected to be primary key.
Foreign Key
Attribute, or set of attributes, within one relation that matches candidate key of
some (possibly same) relation.
Relational Integrity
Null
Represents value for an attribute that is currently unknown or not
applicable for tuple
Deals with incomplete or exceptional data
Represents the absence of a value and is not the same as zero
or spaces, which are values.
Relational Integrity
Entity Integrity
In a base relation, no attribute of a primary key can be null
Referential Integrity
If foreign key exists in a relation, either foreign key value must
match a candidate key value of some tuple in its home relation or
foreign key value must be wholly null
Enterprise Constraints
Additional rules specified by users or database administrators
Mathematical definition of relation
Consider two sets, D1 and D2, where D1 = {2, 4} & D2 = {1, 3, 5}.
Cartesian product, D1 × D2, is the set of all ordered pairs, where the first
element is member of D1 and second element is member of D2.
D1 × D2 = {(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)}
May specify which pairs are in relation using some condition for
selection; e.g.
second element is 1:
R = {(x, y) | x ∈D1, y ∈D2, and y = 1}
first element is always twice the second:
S = {(x, y) | x ∈D1, y ∈D2, and x = 2y}
Mathematical definition of relation
D1 × D2 × D3 =
{(1,2,5), (1,2,6), (1,4,5), (1,4,6), (3,2,5), (3,2,6), (3,4,5), (3,4,6)}
n
Usually we write × Di instead of D1 × D2 × . . . × Dn
i =1
Base Relation
Named relation corresponding to an entity in conceptual schema,
whose tuples are physically stored in database.
View
Dynamic result of one or more relational operations operating on
base relations to produce another relation.
Views
Informally,
relational algebra is a (high-level) procedural language (how data
is to be manipulated), whereas
relational calculus a non-procedural language (what data is
required).
Relational Algebra
Graphical languages provide user with picture of the structure of the relation.
User fills in example of what is wanted and system returns required data in
that format (e.g. QBE).
Choose one of the key attributes of E as the primary key for R (if
the chosen key for E is composite, then the set of simple attributes
that form it will together form the primary key of R).
7
Handling weak entity types
For each weak entity type, say W, in the EER schema, with owner
entity type E,
create a relation
include all the simple attributes (or simple components of
composite attributes) of W
include also as foreign key attributes of R any primary key
attribute(s) of the relations that correspond to the owner entity
type(s)
choose as the primary key of R the combination of the primary
keys of the owner(s) and the partial key of the week entity type W.
7
Handling binary 1 : M relationship types
7
Handling Multi-valued Attributes
7
Handling specialization relationship types