πŸŽ“ Velnov

πŸ—„οΈ SQL Β· Topic 18 of 20

Normalization & Design β€” SQL Questions with Answers

30 practice questions on Normalization & Design, each with the correct answer and a clear explanation of why it is right. Read through them as revision notes, or take this topic as an interactive quiz to test yourself.

0 easy Β· 16 medium Β· 14 hard Β· Part of SQL: Databases from basics to window functions - 20 topics.

Key concepts in this topic

NormalizationDesignRedundancyAnomalies1NFAtomicity2NFPartial dependency3NFTransitive dependencyDesign ruleDenormalizationPerformanceData warehouseER diagramModellingOne-to-manyForeign keysMany-to-manyJunction tableOne-to-oneUNIQUELookup tableSurrogate key

Jump to: Medium Β· Hard

Medium questions (16)

Q1. medium

What is normalization?

  1. A Organising tables to reduce redundancy and prevent update anomalies
  2. B Making all values lowercase
  3. C Sorting data
  4. D Backing up the database

Answer: A β€” Organising tables to reduce redundancy and prevent update anomalies

Normalization splits data into related tables so each fact is stored once. This avoids duplication and the inconsistencies that arise when the same fact lives in many places.

NormalizationDesign

Q2. medium

What is a data redundancy problem?

  1. A The same information stored in multiple places, risking inconsistency when one copy changes
  2. B Too many tables
  3. C Missing indexes
  4. D Slow queries

Answer: A β€” The same information stored in multiple places, risking inconsistency when one copy changes

If a customer's address is copied into every order row, changing it means updating many rows - and missing one leaves conflicting data. Normalization stores it once.

RedundancyAnomalies

Q4. medium

What does First Normal Form (1NF) require?

  1. A Atomic (indivisible) values - no repeating groups or multiple values in one cell
  2. B A primary key only
  3. C No foreign keys
  4. D All numeric columns

Answer: A β€” Atomic (indivisible) values - no repeating groups or multiple values in one cell

1NF forbids storing '555-1234, 555-5678' in one phone column, or columns like phone1, phone2, phone3. Each cell holds one value; repeating data moves to its own table.

1NFAtomicity

Q7. medium

A common summary of 3NF is 'every non-key column depends on...'

  1. A the key, the whole key, and nothing but the key
  2. B any column
  3. C the first column
  4. D no columns

Answer: A β€” the key, the whole key, and nothing but the key

This memorable phrase captures 1NF (atomic, tied to the key), 2NF (the WHOLE key), and 3NF (NOTHING BUT the key). It is a handy design checklist.

3NFDesign rule

Q8. medium

What is denormalization?

  1. A Deliberately adding redundancy back to improve read performance, accepting the update cost
  2. B A design mistake always
  3. C Removing all tables
  4. D The same as normalization

Answer: A β€” Deliberately adding redundancy back to improve read performance, accepting the update cost

Sometimes storing a pre-computed total or a duplicated label speeds up heavy read workloads (reporting, analytics). It trades write complexity and consistency risk for read speed.

DenormalizationPerformance

Q10. medium

What is an ER (Entity-Relationship) diagram?

  1. A A visual model of entities (tables), their attributes, and the relationships between them
  2. B A query plan
  3. C An index structure
  4. D A backup format

Answer: A β€” A visual model of entities (tables), their attributes, and the relationships between them

ER diagrams are the blueprint for a schema: boxes for entities, lines for relationships (one-to-many, many-to-many), and crow's-foot notation for cardinality. Design before you build.

ER diagramModelling

Q11. medium

How is a one-to-many relationship implemented?

  1. A Put a foreign key on the MANY side referencing the ONE side
  2. B A junction table
  3. C Two primary keys
  4. D Duplicate the data

Answer: A β€” Put a foreign key on the MANY side referencing the ONE side

One customer has many orders, so orders.customer_id references customers.id. The foreign key lives on the many side - the most common relationship in databases.

One-to-manyForeign keys

Q13. medium

How is a one-to-one relationship typically implemented?

  1. A A shared/foreign key with a UNIQUE constraint, or by merging into one table
  2. B A junction table
  3. C Two separate databases
  4. D It is impossible

Answer: A β€” A shared/foreign key with a UNIQUE constraint, or by merging into one table

One-to-one splits optional or sensitive attributes (e.g. a user and their extended profile) into a second table sharing the key, enforced UNIQUE. Often the data could just live in one table.

One-to-oneUNIQUE

Q15. medium

What is a surrogate key in design terms?

  1. A An artificial identifier (like an auto-increment id) with no business meaning, used as the primary key
  2. B A natural business value
  3. C A foreign key
  4. D An index

Answer: A β€” An artificial identifier (like an auto-increment id) with no business meaning, used as the primary key

Surrogate keys are stable (they never change) and simple, which is why most designs use them. Natural keys carry meaning but can change, complicating references.

Surrogate keyPrimary key

Q17. medium

What is cardinality in a relationship?

  1. A How many rows on one side relate to rows on the other (one-to-one, one-to-many, many-to-many)
  2. B The number of columns
  3. C The table size
  4. D The index depth

Answer: A β€” How many rows on one side relate to rows on the other (one-to-one, one-to-many, many-to-many)

Cardinality describes the relationship's shape and drives how you implement it (foreign key placement, junction tables). ER diagrams annotate it with crow's-foot symbols.

CardinalityER diagram

Q19. medium

What problem does normalization solve when a customer changes address?

  1. A The address is stored once, so a single UPDATE fixes it everywhere - no missed copies
  2. B It makes the address unchangeable
  3. C It duplicates the address
  4. D Nothing

Answer: A β€” The address is stored once, so a single UPDATE fixes it everywhere - no missed copies

In a denormalized design the address might be copied into every order. Normalized, it lives in one customer row, so one update keeps all data consistent.

Update anomalySingle source of truth

Q21. medium

What is a star schema?

  1. A A denormalized analytics design: a central fact table linked to dimension tables
  2. B A fully normalized design
  3. C A backup strategy
  4. D An index type

Answer: A β€” A denormalized analytics design: a central fact table linked to dimension tables

Data warehouses use star schemas: a fact table (sales) surrounded by dimensions (date, product, store). Deliberately denormalized for fast aggregation, unlike transactional 3NF designs.

Star schemaData warehouse

Q23. medium

Where should a derived value like order total ideally live?

  1. A Usually computed on read (SUM of items) to avoid it going stale - or stored/cached deliberately for performance
  2. B Always duplicated in every row
  3. C In a text file
  4. D It cannot be stored

Answer: A β€” Usually computed on read (SUM of items) to avoid it going stale - or stored/cached deliberately for performance

Storing a total risks it drifting out of sync with the items. Computing it on demand keeps it correct; caching it (with careful maintenance) is a performance-driven denormalization.

Derived dataDenormalization

Q25. medium

What is referential integrity's role in design?

  1. A It guarantees relationships stay valid - foreign keys always point to existing rows
  2. B It sorts the data
  3. C It compresses tables
  4. D It has no role

Answer: A β€” It guarantees relationships stay valid - foreign keys always point to existing rows

Enforced by foreign keys, it prevents orphan records (an order for a deleted customer). It is a cornerstone of trustworthy relational data.

Referential integrityForeign keys

Q27. medium

Why store status codes in a lookup table rather than free text?

  1. A It enforces a fixed set of valid values and lets you rename or add statuses in one place
  2. B It uses more space
  3. C It is slower
  4. D There is no benefit

Answer: A β€” It enforces a fixed set of valid values and lets you rename or add statuses in one place

Free text invites typos ('shpped', 'Shipped', 'SHIPPED') that fragment reports. A lookup table with a foreign key guarantees consistency and central control.

Lookup tableData quality

Q29. medium

What is the single source of truth principle?

  1. A Each fact is stored in exactly ONE place, so it is always consistent
  2. B One table per database
  3. C One user per row
  4. D One index per table

Answer: A β€” Each fact is stored in exactly ONE place, so it is always consistent

Normalization implements this principle. When a fact lives in one place, it cannot contradict itself - the core reason normalized designs are trustworthy.

Single source of truthNormalization

Hard questions (14)

Q3. hard

What are update, insert and delete anomalies?

  1. A Problems from redundancy: updating misses copies, you cannot insert data without unrelated data, and deleting loses needed facts
  2. B Syntax errors
  3. C Index failures
  4. D Types of joins

Answer: A β€” Problems from redundancy: updating misses copies, you cannot insert data without unrelated data, and deleting loses needed facts

For example, if course info lives only in enrolment rows, deleting the last enrolment erases the course entirely (delete anomaly). Normalization prevents these.

AnomaliesNormalization

Q5. hard

What does Second Normal Form (2NF) address?

  1. A Removing partial dependencies - non-key columns must depend on the WHOLE composite key, not part of it
  2. B Removing all keys
  3. C Making columns unique
  4. D Adding indexes

Answer: A β€” Removing partial dependencies - non-key columns must depend on the WHOLE composite key, not part of it

2NF applies when the primary key is composite. If a column depends on only part of the key (e.g. product_name depends on product_id alone in an order_items table), it belongs in a separate table.

2NFPartial dependency

Q6. hard

What does Third Normal Form (3NF) address?

  1. A Removing transitive dependencies - non-key columns must not depend on OTHER non-key columns
  2. B Removing the primary key
  3. C Combining tables
  4. D Adding redundancy

Answer: A β€” Removing transitive dependencies - non-key columns must not depend on OTHER non-key columns

If a table has employee_id (key), dept_id, and dept_name, then dept_name depends on dept_id (a non-key), not directly on the key. 3NF moves department data to a departments table.

3NFTransitive dependency

Q9. hard

When is denormalization justified?

  1. A For read-heavy analytics/reporting where join cost is high and data changes rarely
  2. B Always - normalization is bad
  3. C Never
  4. D Only for small tables

Answer: A β€” For read-heavy analytics/reporting where join cost is high and data changes rarely

Data warehouses often denormalize into star schemas for fast aggregation. For transactional systems that change constantly, normalized designs remain safer. It is a deliberate trade-off, not a default.

DenormalizationData warehouse

Q12. hard

How is a many-to-many relationship implemented?

  1. A With a junction (bridge) table holding foreign keys to both sides
  2. B With one foreign key
  3. C By duplicating rows
  4. D It cannot be modelled

Answer: A β€” With a junction (bridge) table holding foreign keys to both sides

Students and courses: an enrollments table links them, with student_id and course_id. It resolves the many-to-many into two one-to-many relationships and can carry extra data like a grade.

Many-to-manyJunction table

Q14. hard

What is a lookup (reference) table?

  1. A A small table of allowed values (e.g. statuses, categories) referenced by foreign key
  2. B A backup table
  3. C A temporary table
  4. D An index

Answer: A β€” A small table of allowed values (e.g. statuses, categories) referenced by foreign key

Instead of repeating 'pending'/'shipped' text everywhere, store them once in a statuses table and reference by id. This enforces valid values and makes renaming a status a one-row change.

Lookup tableNormalization

Q16. hard

Why can columns like phone1, phone2, phone3 be a design smell?

  1. A They violate 1NF and cap the number of phones; a separate phones table scales cleanly
  2. B They are always correct
  3. C They save space
  4. D They speed up queries

Answer: A β€” They violate 1NF and cap the number of phones; a separate phones table scales cleanly

Repeating-group columns force a fixed maximum and make queries awkward ('find anyone with this number' must check three columns). A related phones table (one row per number) is the normalized solution.

1NFRepeating groups

Q18. hard

What is a functional dependency?

  1. A When one column's value determines another's - e.g. zip_code determines city
  2. B A type of function
  3. C A foreign key
  4. D An index

Answer: A β€” When one column's value determines another's - e.g. zip_code determines city

Functional dependencies are the theory behind normal forms. If A determines B but A is not a key, B usually belongs in a table keyed by A - the essence of 3NF.

Functional dependency3NF

Q20. hard

What is BCNF (Boyce-Codd Normal Form)?

  1. A A stronger 3NF: every determinant must be a candidate key
  2. B Weaker than 1NF
  3. C The same as 2NF
  4. D About indexes

Answer: A β€” A stronger 3NF: every determinant must be a candidate key

BCNF handles edge cases 3NF misses, involving overlapping candidate keys. Most practical designs that reach 3NF are also in BCNF; it matters mainly in complex schemas.

BCNFNormal forms

Q22. hard

What is the main trade-off of a highly normalized design?

  1. A Less redundancy and safer writes, but more joins - which can slow complex read queries
  2. B It is always faster
  3. C It uses more storage
  4. D It has no downsides

Answer: A β€” Less redundancy and safer writes, but more joins - which can slow complex read queries

Normalization optimises for correctness and write integrity. Read-heavy analytical workloads sometimes denormalize to avoid many joins - a conscious balance between the two goals.

Trade-offsJoins

Q24. hard

How do you decide how far to normalize?

  1. A Aim for 3NF by default, then denormalize selectively where measured performance requires it
  2. B Always go to the highest normal form
  3. C Never normalize
  4. D Randomly

Answer: A β€” Aim for 3NF by default, then denormalize selectively where measured performance requires it

3NF is the practical sweet spot for most transactional systems: enough to prevent anomalies without excessive joins. Denormalize only with evidence that it helps a specific workload.

Design strategy3NF

Q26. hard

What is an associative entity?

  1. A Another name for a junction table - it represents the relationship itself and can hold its own attributes
  2. B A primary key
  3. C A view
  4. D An index

Answer: A β€” Another name for a junction table - it represents the relationship itself and can hold its own attributes

The enrollments table between students and courses is an associative entity: it exists because of the relationship and can store attributes about it, like enrolment date and grade.

Associative entityJunction table

Q28. hard

What design issue does a NULL-heavy table often reveal?

  1. A Attributes that apply to only some rows may belong in a separate related table (subtype)
  2. B The table is too small
  3. C Missing indexes
  4. D Nothing

Answer: A β€” Attributes that apply to only some rows may belong in a separate related table (subtype)

If many columns are NULL for most rows (e.g. car-specific fields in a generic products table), those attributes likely belong to a subtype table linked by key - a cleaner, more normalized model.

NULLSubtypesDesign

Q30. hard

Why model the schema (ER diagram) BEFORE writing CREATE TABLE?

  1. A Relationships and keys are hard to change once data exists; a clear model prevents costly restructuring later
  2. B It is required syntax
  3. C It makes queries run faster
  4. D There is no reason

Answer: A β€” Relationships and keys are hard to change once data exists; a clear model prevents costly restructuring later

Schema changes on populated production tables are risky and slow. Designing entities, keys and relationships upfront catches mistakes while they are cheap to fix.

ER diagramPlanning

Practice β€œNormalization & Design” as a quiz