DBMS Fundamentals: Keys, Normalization, and Transactions

← Community · Computer Awareness·By Aman Raj·Published ·11 min read·1,403 words

Every DBMS exam — BSc papers, banking computer awareness, SSC CSE sections — reduces to three pillars: keys (how rows are identified and linked), normalization (how tables are split to remove duplication), and transactions (how concurrent, crash-prone execution stays reliable). This guide builds each pillar with worked examples: a full 1NF → BCNF decomposition, and a concrete ACID/isolation-level table you can revise from directly.

Keys: naming every identifier

Take a student-enrolment table:

enrolment(student_id, student_name, course_id, course_name, instructor, semester)
Key vocabulary, in the order exams ask for it:
  • Super key: any set of columns that uniquely identifies a row — (student_id), (student_id, course_id), (student_id, student_name), … Many of these.
  • Candidate key: a minimal super key — no column can be dropped without losing uniqueness. Here: (student_id, course_id) is a candidate key for the enrolment fact; (student_id) alone is not, because one student takes many courses.
  • Primary key: the candidate key the schema enforces (declared PRIMARY KEY). Others become alternate keys.
  • Foreign key: a column referencing another table's primary key — enrolment.course_id referencing courses(course_id) keeps every enrolment pointing at a real course.
  • Composite key: a key made of two or more columns — (student_id, course_id) above.
  • Unique key: a constraint enforcing uniqueness while still allowing NULLs (unlike a primary key, which allows neither duplicates nor NULLs).

Functional dependency is the engine under all of this. In student_id → student_name, any two rows with the same student_id must have the same student_name. In the enrolment table, student_id → student_name holds, but student_id → course_name does not (one student, many courses). Writing dependencies correctly is 80% of a normalization answer.

Normalization: 1NF to BCNF, worked

The problem table

student_idstudent_namecourse_idcourse_nameinstructoroffice
S1AshaC101, C201DBMS, OSRao, IyerR12, R14
S2BenC101DBMSRaoR12
S3ChitraC201OSIyerR14

Three anomalies live here:

  • Update anomaly: rename Rao's office → must edit every row where Rao teaches (and miss one, and the data contradicts itself).
  • Insert anomaly: a new instructor with no students cannot be recorded at all (no student_id to put).
  • Delete anomaly: delete S2's last enrolment and you may lose the fact that Rao teaches C101.

1NF — atomic values only

No repeating groups, no comma lists. Every cell holds one value.

student_idstudent_namecourse_idcourse_nameinstructoroffice
S1AshaC101DBMSRaoR12
S1AshaC201OSIyerR14
S2BenC101DBMSRaoR12
S3ChitraC201OSIyerR14

Key: (student_id, course_id). The list-valued cell is gone.

2NF — no partial dependency on part of a composite key

student_id → student_name depends on half the key; course_id → course_name, instructor, office depends on the other half. Split:
  • students(student_id, student_name)
  • courses(course_id, course_name, instructor, office)
  • enrolments(student_id, course_id) — pure junction table

Each non-key column now depends on the whole key of its table.

3NF — no transitive dependency

In courses, we have course_id → instructor → office. The office depends on the instructor, who depends on the key — a transitive chain. Split again:

  • courses(course_id, course_name, instructor)
  • instructors(instructor, office)

Now every non-key column depends on the key, the whole key, and nothing but the key (in 3NF terms: no non-key column depends on another non-key column).

BCNF — every determinant is a candidate key

BCNF closes the remaining corner case: if X → Y holds, X must be a candidate key. Classic counter-example: a student-advisor table keyed (student_id, course_id) with advisor → department where one advisor advises one department but advises many students. (student_id, course_id) is the key, but advisor determines department and advisor is not a key → 3NF yes, BCNF no. Decomposing into (advisor, department) and (student_id, advisor, course_id) reaches BCNF.

Exam shortcut table:
Normal formRemovesTest question to ask
1NFRepeating groups, multi-valued cellsAre all values atomic?
2NFPartial dependencies on composite keyDoes any column depend on only part of the key?
3NFTransitive dependenciesDoes any non-key column determine another non-key column?
BCNFEvery non-trivial determinant is a candidate keyFor each X → Y, is X a candidate key?

Higher normal forms (4NF, 5NF) handle multi-valued dependencies and join dependencies — rarely asked beyond definitions in BSc and awareness exams.

Transactions and ACID

A transaction is a logical unit of work: BEGIN; UPDATE accounts SET balance = balance - 500 WHERE id = 1; UPDATE accounts SET balance = balance + 500 WHERE id = 2; COMMIT;

PropertyMeaningExam one-liner
AtomicityAll statements commit, or none doThe crash halfway through a transfer must not leave money vanishing
ConsistencyThe database moves from one valid state to anotherConstraints and invariants hold at COMMIT
IsolationConcurrent transactions do not corrupt each otherTwo transfers running at once behave as if serialised
DurabilityCommitted data survives crashesOnce COMMIT returns, the data is on disk (WAL/redo logs)

Concurrency anomalies and isolation levels

Without isolation, three anomalies appear as schedules interleave:

  • Dirty read: T2 reads a row T1 wrote but has not committed. T1 rolls back → T2 read fiction.
  • Non-repeatable read: T2 reads a row; T1 updates and commits it; T2 re-reads and sees a different value.
  • Phantom read: T2 runs SELECT COUNT(*) WHERE region = 'North'; T1 inserts a North row and commits; T2 re-runs and gets a larger count.

The SQL standard defines four isolation levels as the fix ladder:

Isolation levelDirty readNon-repeatable readPhantom readConcurrency
Read Uncommittedpossiblepossiblepossiblehighest
Read Committedpreventedpossiblepossiblehigh
Repeatable Readpreventedpreventedpossible*medium
Serializablepreventedpreventedpreventedlowest

\* PostgreSQL's Repeatable Read uses snapshot isolation and also prevents phantoms; the SQL standard allows them at this level. This difference is itself a favourite viva question — state which engine you mean.

Read Committed (PostgreSQL's default) is the usual engineering choice: no dirty reads, straightforward locking/MVCC semantics. Serializable gives the strongest guarantee and the most aborts under contention; modern engines implement it via SSI (serializable snapshot isolation) rather than heavy locking.

Schedule vocabulary (BSc paper favourites)

  • Serial schedule: transactions run one after another. Always correct, terrible throughput.
  • Serialisable schedule: interleaved, but the result equals some serial order. The goal.
  • Conflict serialisability: a schedule whose precedence graph is acyclic — testable, slightly stricter than view serialisability.
  • Two-phase locking (2PL): transactions acquire locks (growing phase) then only release them (shrinking phase). Guarantees conflict serialisability; can deadlock (resolved by timeouts, wait-die, or deadlock detection).

Common exam mistakes

  • Calling (student_id) a candidate key of enrolments. One student, many courses → it does not identify rows. The composite key does.
  • Confusing 2NF and 3NF. 2NF is about partial dependence on a composite key; 3NF is about transitive dependence. A table with a single-column key is automatically 2NF — it can still fail 3NF.
  • Defining ACID as "four database features." It is the contract of a transaction, not of the DBMS product.
  • Saying "Repeatable Read prevents phantoms" without naming the engine. Standard SQL says no; PostgreSQL's implementation says yes.
  • Forgetting foreign keys enforce referential integrity. A foreign key is not just an index — it blocks or cascades on insert/update/delete of parents.

Practice on PixoQuest

Keys, normal forms, and ACID are definition-and-scenario topics — exactly what short quiz rounds drill well. The PixoQuest GK: World and Science course covers computer-awareness fundamentals including DBMS basics in quick interactive sessions. Quiz for definitions, then type queries against a real engine for instinct — normalization only pays off when you can actually write the joins and constraints.

Bottom line

Keys identify rows (candidate → primary) and link tables (foreign). Normalization splits tables until every column depends on the key, the whole key, and nothing but the key — 1NF removes lists, 2NF removes partial dependencies, 3NF removes transitive ones, BCNF demands every determinant be a candidate key. Transactions promise ACID, and isolation levels trade concurrency against dirty, non-repeatable, and phantom reads. Master those three pillars and most DBMS exam questions answer themselves.

Sources & further reading

  • PostgreSQL documentation, Transaction Isolation (dirty/non-repeatable/phantom behaviour per level): https://www.postgresql.org/docs/current/transaction-iso.html
  • PostgreSQL documentation, Constraints (primary, unique, foreign keys): https://www.postgresql.org/docs/current/ddl-constraints.html
  • PostgreSQL documentation, Explicit Locking (two-phase locking, deadlock notes): https://www.postgresql.org/docs/current/explicit-locking.html
  • Silberschatz, Korth and Sudarshan, Database System Concepts — companion site: https://www.db-book.com/
  • ISO/IEC 9075, SQL — Foundation (transaction isolation level definitions)

The enrolment example and its functional dependencies are invented for this exercise. The BCNF advisor counter-example is the textbook case from the normalization literature, restated here in exam form.

Frequently asked questions

What is the difference between a primary key and a candidate key?

A candidate key is any minimal set of columns that uniquely identifies each row — a table can have several. The primary key is the one candidate key the designer chooses to enforce; the others become alternate keys.

What is a foreign key?

A column (or set of columns) that references the primary key of another table. It enforces referential integrity: you cannot insert an order for a customer that does not exist, and deleting a referenced parent row is blocked or cascaded according to the constraint.

What is normalization in simple terms?

The process of splitting tables so that each non-key column depends on the key (1NF-3NF) or the whole key and nothing but the key (BCNF). The goal is to remove update, insert, and delete anomalies caused by duplicated data.

What does ACID stand for?

Atomicity (all-or-nothing execution), Consistency (constraints hold before and after), Isolation (concurrent transactions do not see each other's half-done work), Durability (committed data survives crashes).

What is the difference between a dirty read and a phantom read?

A dirty read is reading a row another transaction wrote but has not yet committed. A phantom read is re-running a query and seeing new rows that another transaction inserted. Non-repeatable read is re-reading one row and finding it changed between the two reads.

DBMSnormalizationACIDkeyscomputer awareness

Published under the PixoQuest editorial policy.