Database Notes
Database Notes
– Atomicity requires that a transaction should either be executed in its entirety or not all
– Consistency assures that a transaction brings the database from one consistent state
to another
– Isolation ensures that the e ect of concurrent transactions should be the same as if
they would have been executed in isolation
– Durability ensures that the database changes made by a transaction declared
successful can be made permanent under all circumstances
Architecture of a DBMS
ff
• Categorisation based on data model:
- Hieararchical DBMSs
- Network DBMSs
- Relational DBMSs
- Object-orientated DBMSs
- Object-Relational DBMSs (ORDBMSs)
- XML DBMSs
- NoSQL DBMSs
SUPPLIER
SUPNR SUPNAME SUPADDRESS SUPCITY SUPSTATUS
21 Deliwines 240, Avenue of the Americas New York 20
32 Best Wines 660, Market Street San Francisco 90
37 Ad Fundum 82, Wacker Drive Chicago 95
ENTITIES 52 Spirits & co. 928, Strip Las Vegas NULL
68 The Wine Depot 132, Montgomery Street San Francisco 10
69 Vinos del Mundo 4, Collins Avenue Miami 92
…
ATTRIBUTES
• Relationship Types
- De nition
- Degree and Roles (Unary: degree 1, binary: degree 2, ternary: degree 3)
- Cardinalities (if min If 0: partial participation / If 1: total participation or existence dependency)
- Relationship Attribute Types RNR
HNR
• Weak Entity Types (always existent dependent from owner entity type) HNR Room
0..N
BELONGS TO
1..1 Hotel
Specialization
Process of de ning a set of subclasses of an entity type. “IS A” relationship.
(ie. Artist superclass with subclasses Singer and Actor)
• Disjointness constraint
ANR
• Completeness constraint
- Total specialization: every entity in the superclass must be a member of some
subclass
- Partial specialization: an entity to only belong to the superclass and to none of the
subclasses
Categorization
A category is a subclass that has several possible
superclasses (di erent entity types)
The category represents a collection of entities that is a
subset of the union of the superclasses. (Represented as U)
• Disjointness constraint
- Total categorisation: all entities of the superclasses belong to the subclass
- Partial categorisation: not all entities of the superclasses belong to the subclass
• Note: total categorization can also be represented as a specialization/
generalization!
Aggregation
Particular relationship type combined or aggregated into a higher-
CNR PNR
Useful when the aggregate entity type has its own attribute types 1..M
PARTICIPATION
date
1..1
CONTRACT CONTNR
fi
fi
ff
Designing the EER Model
1. Identify the entity types
2. Identify the relationship types and assert their degree
3. Assert the cardinality ratios and participation constraints (total versus partial participation)
4. Identify the attribute types and assert whether they are simple or composite, single or
multiple valued, derived or not
5. Link each attribute type to an entity type or a relationship type
6. Denote the key attribute type(s) of each entity type
7. Identify the weak entity types and their partial keys
8. Apply abstractions such as generalization/specialization, categorization and aggregation
9. Assert the characteristics of each abstraction such as disjoint or overlapping, total or
partial
Domain
• speci es the range of admissible values for an attribute type (ie. gender domain, time
domain // or takes NULL value
• the value of each attribute type must be an atomic and single value from its domain.
Keys
- Superkeys
• uniqueness constraint
• redundant attribute types
- Candidate Keys
• an attribute or set of attributes that can uniquely identify a tuple (other than primary
key)
- Primary Keys
• identify tuples in the relation, to establish connections and for storage purposes
• Entity integrity constraint: satisfy a NOT NULL constraint
- Alternative key
• Other candidate keys are then referred to as alternative keys
- Foreign Keys
• (referential integrity constraint)
• The same domains as the primary key attributes
• Either a value of PK for some tuple in a state or is NULL
Relational Constraints
The value of each attribute type A must be an atomic and single value from
Domain constraint
the domain dom(A).
Key constraint Every relation has a key that allows to uniquely identify its tuples.
The attribute types that make up the primary key should always satisfy a
Entity integrity constraint
NOT NULL constraint.
Referential integrity A foreign key has the same domain as the primary key attribute type(s) it
constraint refers to and either occurs as a value of PK or NULL.
fi
Normalization
- Logical Level: to understand the meaning of the data and formulate correct queries)
- Implementation level: e cient storage usage and reduced risk of inconsistent updates
• Isolation Levels
fl
fi
Compatibility Matrix
Isolation Levels