2 ms·
Some of the tables have dozens of columns, with most of the rows being full of NULL values. This is generally addressed in a relational design with a star sche
by yummyfajitas 12y ago
Some of the tables have dozens of columns, with most of the rows being full of NULL values.
This is generally addressed in a relational design with a star schema. First create a dimension table:
CREATE TABLE person (
id BIGINT PRIMARY KEY NOT NULL
)
Then create fact tables:
CREATE TABLE person_name (
person_id BIGINT REFERENCES person(id) UNIQUE,
name VARCHAR(128) NOT NULL
)
CREATE TABLE person_bank_details (
person_id BIGINT REFERENCES person(id) UNIQUE,
bank_detail ....
)
This avoids large numbers of rows containing nulls, but it violates a normal form. The mnemonic is that the table must contain the Key, the whole key, and nothing but the key, so help me Codd. Anytime you have a "REFERENCES table(pk) UNIQUE", you violate the "whole key" bit.