Normalization, Transactions Flashcards
Unnormalized form
probably no relationships, just one large table (pro: no joins, easy to restructure, good for NoSQL; con: data duplication, empty attributes, non-atomic attributes)
First normal form
each attribute must contain atomic values
Second normal form
must be in 1NF and all non-key columns must describe the primary key
Third normal form
must be in 2NF, cannot have attributes that provide facts about non-key attributes (“about the key, the whole key, and nothing but the key”)
Transaction
sequence of statements/queries executed as a single unit (all-or-nothing)
ACID properties
guarantee transactions maintain the integrity of the database, Atomicity, Consistency, Isolation, Durability
Atomicity
require that each transaction be all-or-nothing, they are never “in progress”
Consistency
a transaction must change the database from one valid state to another valid state, must maintain constraints
Isolation
defines WHEN changes to the database are visible to others
Durability
guarantees that successful transactions are committed to the database
Isolation levels
Serializable, repeatable reads, read committed, read uncommitted
Lock
mechanism for securing data for a transaction
2PL
two-phase locking protocol, use a read lock and a write lock
Expanding phase
first part of 2PL, locks are acquired before the transaction begins
Shrinking phase
last part of 2PL, locks are released after the transaction commits/rolls back