1. Learn
  2. /
  3. Courses
  4. /
  5. Creating PostgreSQL Databases

Exercise

Too much normalization

Recall the definition of the loan table.

CREATE TABLE loan (
    borrower_id INTEGER REFERENCES borrower(id),
    bank_id INTEGER REFERENCES bank(id),
    approval_date DATE NOT NULL DEFAULT CURRENT_DATE,
    gross_approval DECIMAL(9, 2) NOT NULL,
    term_in_months SMALLINT NOT NULL,
    revolver_status BOOLEAN NOT NULL DEFAULT FALSE,
    initial_interest_rate DECIMAL(4, 2) NOT NULL
);

A new design for this table has been suggested to satisfy 1NF. The revised table definition replaces approval_date with approval_month, approval_day, and approval_year:

CREATE TABLE loan (
    ...
    approval_month SMALLINT,
    approval_day SMALLINT,
    approval_year SMALLINT,
    ...
);

This exercise demonstrates how too much normalization can allow for the insertion of invalid data.

Instructions

100 XP
  • Remove the INSERT INTO statement that, if executed, would result in invalid data being inserted into the table.