databases Flashcards
(129 cards)
top down database design
create ER diagrams (graphical description): start with a set of system requirements and identify entities and attributes then construct relational data model i.e. tables for entities
bottom up database design
start with initial tables for entities and their attributes –> redesign in a “better” way: trickier for larger databases so need a formalization of process
purpose of normalization
- relations represent real world entities
- single valued columns
- avoid redundancy
- easier to update and maintain correctly without anomalies
no redundancy
each data item is stored only once: -minimises space required, - simplifies maintenance
consequence of redundancy
- takes up unnecessary space
- when modifying data, have to modify in different places
- risk of inconsistencies
exception for redundancy
foreign keys: act as pointers
what causes redundancy
- set valued attributes –> multiple rows in corresponding table. e.g. more than one attribute for a particular entry in the table
- dependency e.g. postcode and town are dependent on each other
define redundancy
repeating data in multiple different locations
modification anomaly
failure to maintain all existing instances of a specific value
deletion anomaly
losing other values as a side effect of deleting data. e.g. deleting staff member and deleting info of their workplace simultaneously if unnormalised
insertion anomaly
when adding more data items, much more irrelevant data needs to be added. adding rows forces us to add info about other entities –> can lead to inconsistency
e.g. adding details of new surgery, with no staff, add null to staff fields
overcoming redundancy
schema refinement (decomposition): use 2+ relations to store the original data. can be done manually for smaller tables but formalisation needed for larger DB
functional dependencies specify…
- specify which are candidate, primary and foreign keys
- specify which attributes to combine in the new tables
simple key
key consists of only one attribute
composite key
key consists of several attributes
candidate key
minimal set of attributes whose values uniquely identify tuples.
functionally determines all attributes in a relation
primary key
the candidate key selected to identify rows uniquely within a table
what is functional dependency
describes relationship between two attributes in the same relation
if B is functionally dependent on A
Represent as A -> B
If we know attribute values for A, then we know the unique attribute values of B.
Each value of A is associated with exactly one value of B
determinant
set of attributes on the left hand side
dependent
set of attributes on the right hand side
full functional dependency
B is not functionally dependent on any proper subset of A, i.e. B is functionally dependent on ALL the primary key if composite key, not just individual parts
partial functional dependency
B remains functionally dependent on at least one proper subset of A
transitive functional dependency
if A->B and B->C functional dependencies exist, then the functional dependency A -> C also exists = transitive