A surrogate key is an artificially assigned primary-key value, used when business data does not provide a reliable unique identifier. Common choices are monotonically increasing numbers and UUIDs. section 3.2.2
Practical design choices include:
- Use an externally generated identifier when the source dataset already supplies stable IDs. section 3.2.2
- Generate numeric identifiers with a database sequence when the table needs its own artificial key. section 3.3.1
- Keep business uniqueness separately constrained; a surrogate key does not replace rules such as unique validity dates. section 3.3.1
Sequence-backed price identifiers
CREATE SEQUENCE IF NOT EXISTS prices_id INCREMENT BY 1 MINVALUE 10; CREATE TABLE IF NOT EXISTS prices ( id INTEGER PRIMARY KEY DEFAULT(nextval('prices_id')), value DECIMAL(5,2) NOT NULL, valid_from DATE NOT NULL, CONSTRAINT prices_uk UNIQUE (valid_from) ); section 3.3.1
Figure 3.1 Energy consumption schema
Use the schema diagram to see how surrogate and referenced keys fit into the energy-consumption tables. section 3.2.2


