Relational Databases and Normalisation
Core Info and Definitions
A relational database contains tables, making use of relations between them to store data with minimal data redundancy.
Normalisation is a process used to come up with the best possible database design by following a set of formal rules. It ensures:
Transaction Processing and ACID
ACID
A rule that requires a transaction to be fully completed or not started at all.
E.g. Rolling back changes if a system crashes mid-payment.
ConsistencyAny changes to the database must retain its overall state/integrity.
E.g. if an attempt is made to add students beyond maximum capacity, it fails.
IsolationEach transaction is executed and committed to the database in isolation.
E.g. record locking.
DurabilityOnce a transaction has been committed, it must be processed until completion. If it requires multiple actions, all of them must be completed before committing.
I.e. saving changes.
Transaction Processing
Measures need to be taken in order to ensure that multiple users using a database does not harm referential integrity.
Record locking prevents simultaneous access to a record to prevent updates from being lost or inconsistencies in data arising.
However, deadlock can occur. This is when a committed process depends on data from a locked record, which is locked because of a running process that depends on another record locked by the former process. This can be solved with one of the following:
Timestamp ordering
Commitment ordering
Redundancy
First Normal Form
- A table contains unique records.
Second Normal Form
- The table is in first normal form.