Skip to content
Dev Dump

DBMS Fundamentals

A DBMS provides query parsing, optimization, storage management, concurrency control, and recovery—all abstracted from the application layer.

DBMS Architecture Overview

Key responsibilities: Query optimization, buffer management, lock management, WAL/recovery, access control.


ModelStructureExamplesTrade-offs
RelationalTables + SQLPostgreSQL, MySQL, Oracle, SQL ServerACID guarantees, mature tooling, vertical scaling limits
DocumentJSON/BSON docsMongoDB, CouchDB, FirestoreSchema flexibility, denormalized reads, weaker consistency
Key-ValueHash mapRedis, DynamoDB, etcd, MemcachedO(1) lookups, no range queries, limited querying
Wide-ColumnColumn familiesCassandra, HBase, ScyllaDBWrite-optimized, time-series friendly, complex data modeling
GraphNodes + EdgesNeo4j, Amazon Neptune, ArangoDBRelationship traversal, poor for non-graph workloads

ER diagrams translate business requirements into schema design. Key mappings:

ER ConceptRDBMS Implementation
EntityTable
AttributeColumn
RelationshipFK or junction table
TypeImplementationWatch out for
1:1FK with UNIQUE on either sideOften indicates table can be merged
1:NFK on the “many” sideIndex the FK column
M:NJunction table with composite PKCan become a bottleneck; consider denormalization
  • Derived: Compute at read-time or materialize with triggers/generated columns
  • Multivalued: Normalize into separate table or use array types (Postgres [])
  • Composite: Flatten into columns or use structured types (JSONB)

ConstraintEnforcementOperational Impact
PRIMARY KEYUnique + NOT NULLClustered index in most engines
FOREIGN KEYReferential checksWrite overhead; consider DEFERRABLE for bulk loads
CHECKDomain validationExecuted per-row; keep simple
UNIQUEPrevents duplicatesCreates index; NULLs typically allowed
TriggersCustom logicHidden complexity; prefer app-layer when possible

Key TypeDefinitionUsage Notes
PrimaryUnique row identifierImmutable, indexed, one per table
CandidateColumns that could be PKMinimal set guaranteeing uniqueness
CompositeMulti-column PKCommon in junction tables
ForeignReference to another table’s PKIndex for join performance
UniqueUniqueness without PK semanticsAllows NULLs (behavior varies by engine)
AspectSurrogate (UUID/Auto-inc)Natural (email, SKU)
StabilityImmutableMay change → cascading updates
SizeFixed (8B int, 16B UUID)Variable
IndexingPredictableCan be suboptimal
DebuggingOpaqueHuman-readable

Recommendation: Use surrogates for PKs; enforce natural keys via UNIQUE constraints.


PropertyGuaranteeImplementation
AtomicityAll-or-nothingWAL + rollback segments
ConsistencyConstraints honoredConstraint checks at commit
IsolationConcurrent txn separationLocking or MVCC
DurabilitySurvives crashesWAL fsync before commit
LevelPhenomena AllowedUse Case
Read UncommittedDirty readsAlmost never appropriate
Read CommittedNon-repeatable readsDefault in Postgres, Oracle
Repeatable ReadPhantom readsDefault in MySQL InnoDB
SerializableNoneFinancial transactions, inventory

Transaction Lifecycle States

Performance vs. Correctness

Higher isolation = more locking/aborts. Profile your workload. Many “Serializable” requirements can be relaxed with careful schema design or optimistic locking at the app layer.