Databases

Table of Contents

Database design: Conceptual models

Three phases:

Conceptual models: Entity-Relationship & UML

ER diagram

static, models the structure and not operations. no methods or functions.

Entity sets

entity is an abstract object (person, company, event..)

entitties have attributes (names, addresses, ...)

entity set is is a collection of similar entities (those sharing the same attributes).

represented by a set of attributes - descriptive properties possessed by all entities. the domain is set of permitted values for each attribute.

attribute types:

Weak entity sets

a weak entity set doesn't have a primary key. its existence depends on existence of an identifying entity set.

there has to be a total, one-to-may relationship set from identifying to weak entity set, shown by double diamond.

discriminator: a partial key, distinguishing weak entity only in combination with identifying entity. denoted by dashed underline.

primary key of weak entity set is combination of discriminator and primary key of identifying entity set.

Relationship sets

a relationship is association among several entities (a tuple (e₁, e₂, ...) of entities)

a relationship set is a set of relationship of same kind. i.e. a set of tuples (e₁, e₂, ...) where e₁ ∈ E₁, e₂ ∈ E₂, etc. Can have attributes.

example in UML with a relationship set plays-in and role indicators:

Relationship set example

cardinality limits express number of entities to which another entity can be associated via relationship set:

if cardinalities are not given, the default is many-to-many.

total participation: every entity in the entity set participates in at least one relationship in the relationship set

partial participation: entities may not participate in any relationship in the set

degree of a relationship set is number of entity sets participating in the relationship.

Is-a (inheritance)

lower-level entity sets are subgroups of the higher-level entity sets (e.g. an employee 'is a' person)

Is a example

lower-level entity sets inherit all attributes and relationships of the higher-level entity sets

you can go top-down and find subgroups (specialisation) or bottom-up and combine entity sets (generalisation)

constraints:

Aggregation

treat relationship set as an abstract entity. allows relations between relations.

Summary

ER symbols 1 ER symbols 2

UML vs ER

attributes are shown within box of entity set, not as separate ellipses.

binary relationships are a line connecting entity sets, with name of relationship next to line.

if relationship set has attributes, name of relationship set is written in box along with attributes of relation; box is connected with dashed line to the relation line.

non-binary relationship sets are drawn with a diamond.

important differences: