Redundancy Risks

Difficulty: Beginner

Question

Why is data redundancy considered bad in a relational database? Explain with the types of anomalies it causes.

Answer

Redundancy means storing the same fact in more than one place, and it is risky because those copies can drift apart. When one copy is updated and another is not, the database holds two contradictory answers to the same question. Redundancy also causes insert and delete anomalies and wastes storage, which is why normalization exists.

A concrete example

Imagine one table for college placements:

student_idstudent_namecompanycompany_citypackage_lpa
1AshaZohoChennai8
2RohanZohoChennai8
3MeeraRazorpayBengaluru18

The fact "Zoho is in Chennai" is stored once per student placed there.

The three anomalies

  • Update anomaly: Zoho's office for freshers moves. You update row 1 but miss row 2. Now the table says Zoho is in two cities at once, and reports disagree.
  • Insert anomaly: a new company registers for campus hiring but has not placed anyone yet. You cannot record its city without inventing a fake student row or using NULLs in the key columns.
  • Delete anomaly: Meera withdraws and her row is deleted. You also lose the only record that Razorpay is in Bengaluru.

All three come from mixing two different entities (students and companies) in one table.

How normalization fixes it

Split the table so each fact lives once:

  • companies(company_id, name, city)
  • placements(student_id, company_id, package_lpa)

Now the city is updated in one row, a company can exist with no placements, and deleting a placement leaves the company intact. This is what Second and Third Normal Form formalize: non-key attributes must depend on the whole key and only on the key.

Other costs of redundancy

  • Storage and memory: duplicated text makes tables and indexes larger, so fewer rows fit in cache.
  • Write cost: one logical change becomes many physical writes, and each must be kept in sync.
  • Harder constraints: you cannot easily enforce "every Zoho row has the same city" with a simple constraint.

When redundancy is deliberate

Normalization is not an absolute rule. Teams intentionally denormalize when reads vastly outnumber writes or when joins become a bottleneck:

  • Storing total_amount_paise on orders even though it can be computed from order_items.
  • Copying the delivery address onto the order, because the order must remember the address at checkout time even if the user edits it later. This is a historical snapshot, not really redundancy.
  • Read models, caches, materialized views and star schemas in a data warehouse.

The rule of thumb: redundancy is acceptable when there is one clear source of truth and a reliable mechanism (trigger, transaction, event, scheduled refresh) that keeps copies consistent.

Three anomalies caused by redundancy. Each anomaly comes from storing company facts inside student rows.
AnomalyWhat goes wrong
UpdateChange a duplicated valueSome copies updated, others stale
InsertAdd a company with no studentsNo valid row to store it in
DeleteRemove the last student at a companyCompany details lost too

Code examples

Normalized design that removes the anomalies

CREATE TABLE companies (
  company_id BIGSERIAL PRIMARY KEY,
  name       TEXT NOT NULL UNIQUE,
  city       TEXT NOT NULL
);

CREATE TABLE placements (
  student_id  BIGINT NOT NULL REFERENCES students(id),
  company_id  BIGINT NOT NULL REFERENCES companies(company_id),
  package_lpa NUMERIC(5,2) NOT NULL,
  PRIMARY KEY (student_id, company_id)
);

-- Changing a city is now one row, one place
UPDATE companies SET city = 'Chennai' WHERE name = 'Zoho';

Each fact lives in exactly one table, so updates, inserts and deletes cannot create contradictions.

Key points

  • Redundancy = the same fact stored in multiple places.
  • Update anomaly: copies disagree after a partial update.
  • Insert anomaly: cannot record a fact without an unrelated entity.
  • Delete anomaly: deleting one fact removes another fact by accident.
  • Controlled denormalization is fine with one source of truth and a sync mechanism.

Common follow-up questions

  • What is the difference between 2NF and 3NF?
  • When would you intentionally denormalize a schema?
  • How do materialized views help with read-heavy workloads?
  • Is storing the shipping address on an order redundant? Why or why not?

Interview tips

  • Use a tiny table example and name all three anomalies; interviewers often check for insert and delete, not just update.
  • Connect the fix to normalization (2NF and 3NF) in one sentence.
  • Close with when denormalization is acceptable to show practical judgment.

Concepts covered

Data Redundancy, Update Anomaly, Insert Anomaly, Delete Anomaly, Normalization

More Database Design questions