Your database already tracks created_at and updated_at, but neither one tells you what a price actually was on the day a customer bought, or when a plan change really took effect. Modeling time in databases properly means separating three distinct concepts — row metadata, event time, and valid time — and the last one is what effective-dated rows, built from valid_from and valid_to columns, are designed to capture.

The three time concepts are: created_at/updated_at (when the row changed in your database), event time (when something actually happened), and valid time (the period during which a fact was true, tracked with valid_from/valid_to). Only the third one lets you answer "what was the price on the day of purchase" months after the fact.

Every Row Has Three Clocks — Most Schemas Only Track One

Every business fact carries three independent timestamps: when your system recorded it, when it actually happened in the world, and how long it stayed true. Most tables only capture the first pair — created_at and updated_at — which is why "what was true back then" questions turn into forensic archaeology through logs and backups.

That gap is invisible until someone asks a question your schema was never built to answer. A support ticket references a price from four months ago. A finance audit needs to reconstruct which discount code was active on a specific transaction date. A customer disputes a charge and swears the plan terms were different when they signed up. updated_at tells you the row changed at some point — it says nothing about what was true before the change, or for how long.

Time conceptQuestion it answersTypical columnsWho generates it
Transaction timeWhen did the database learn this?created_at, updated_atThe system / ORM, automatically
Event timeWhen did this actually happen?occurred_at, purchased_at, submitted_atThe real-world event
Valid timeDuring what period was this fact true?valid_from, valid_to (or effective_date / expiration_date)The domain model, deliberately

Transaction time is bookkeeping — useful for debugging and change tracking, but it describes your database, not your business. Event time is when something happened in reality, independent of when your pipeline ingested it. It's the same distinction product analytics teams lean on when they reconstruct a customer journey from raw events, not from whenever the warehouse happened to process them.

Valid time is different again: it's not an instant, it's a span — the period during which a fact, like a price or a plan tier, was actually in effect.

Conflating these three is the root cause of most "why doesn't the data match reality" incidents. Before you can model valid time correctly, you need to be honest about what the row is even representing — a question covered in our guide to what counts as an entity.

Is a price change an update to an existing fact, or a new fact entirely? For temporal data, it's almost always the latter. For the broader foundations this article builds on, see our complete guide to data modeling.

Why "What Was the Price on the Day of Purchase" Breaks a created_at-Only Schema

A pricing table with only created_at can tell you when a price row was inserted — it cannot tell you which price applied to an order placed three weeks ago, after two subsequent price changes overwrote it. Without a validity period attached to each price, answering the historical question means reconstructing the past from update logs, backups, or, worse, memory.

Picture a typical SaaS pricing table:

CREATE TABLE prices (
  id UUID PRIMARY KEY,
  plan_id UUID NOT NULL,
  amount_cents INTEGER NOT NULL,
  currency CHAR(3) NOT NULL,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

The moment a price changes, one of two things happens, and both are wrong:

  1. You UPDATE the row in place. The old amount is gone. updated_at moves forward, but there is no way to answer "what was amount_cents on May 3rd" — that fact was overwritten, not preserved.
  2. You insert a new row and hope created_at is good enough. Now you have multiple rows per plan with no explicit end date on the earlier ones, so "which one applied on May 3rd" becomes a fragile MAX(created_at) WHERE created_at <= '2026-05-03' query that breaks the moment two changes land close together or a correction gets backdated.

Imagine a customer who subscribed at $49/month, the price moved to $59 two months later, and a billing dispute surfaces six months after that. Whoever handles the dispute needs to prove, with a query and not a guess, what the customer agreed to pay on the day they purchased.

This isn't a hypothetical compliance nicety — revenue recognition standards like ASC 606 explicitly require evidence of the price and terms in effect at the time of a transaction, not the current price. A schema that can only answer "what is the price now" cannot support that requirement.

Effective-Dated Rows: The Pattern That Actually Answers the Question

Effective dating solves this by giving every fact its own start and end: instead of overwriting a price, you close the old row's valid_to and insert a new row with a fresh valid_from in the same transaction. The query "what was true on date X" then becomes a simple range check instead of a log-mining exercise.

Here's the same table, modeled with effective dating:

CREATE TABLE plan_prices (
  id UUID PRIMARY KEY,
  plan_id UUID NOT NULL REFERENCES plans(id),
  amount_cents INTEGER NOT NULL,
  currency CHAR(3) NOT NULL,
  valid_from TIMESTAMPTZ NOT NULL,
  valid_to TIMESTAMPTZ,          -- NULL = currently in effect
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  CONSTRAINT no_overlapping_price EXCLUDE USING gist (
    plan_id WITH =,
    tstzrange(valid_from, valid_to, '[)') WITH &&
  )
);

That EXCLUDE constraint, built on PostgreSQL's native range types, is doing real work: it guarantees at the database level that a plan can never have two overlapping "currently in effect" prices, so your history stays consistent even under concurrent writes. With that in place, the history for one plan looks like this:

plan_idamount_centsvalid_fromvalid_to
plan_pro49002026-01-01T00:00Z2026-05-15T00:00Z
plan_pro59002026-05-15T00:00ZNULL (current)

Answering "what was the price on the day of purchase" is now one query, not an investigation:

SELECT amount_cents
FROM plan_prices
WHERE plan_id = 'plan_pro'
  AND valid_from <= '2026-03-10'
  AND (valid_to IS NULL OR valid_to > '2026-03-10');

Three rules keep effective-dated tables trustworthy:

  1. Never mutate the price field in place. Close the old row's valid_to and insert the new row in the same transaction, so there's never a moment where the fact has no valid row covering it.
  2. Enforce non-overlapping ranges. Use an exclusion constraint or equivalent application-level locking — a query for a single valid instant should never be able to return two rows.
  3. Keep valid_to nullable to mean "currently in effect," but make sure only the newest row per key is allowed to hold that null, so "current" stays unambiguous.

Closing a row by stamping valid_to instead of deleting or overwriting it is the same instinct behind preferring soft deletes to hard deletes — you're choosing an end-timestamp over destructive removal, for exactly the same reason, as covered in soft delete vs. hard delete modeling. It's worth sketching this relationship before you write a line of DDL: an ERD forces you to decide whether valid time belongs on the entity itself or on a separate history table, which is the same discipline argued for in draw the ERD first.

This is exactly the gap Prodinja's Data Modelling tool is built to close in the schema-design step itself. Instead of hand-rolling exclusion constraints and remembering to add valid_from/valid_to every time a "changes over time" entity shows up, you add valid-from and valid-to as attributes directly on the entity, and the generated SQL DDL carries the effective-dating pattern through — so the schema represents when a fact was true, not just when the row happened to be written.

Time Zones Are Where Effective Dating Quietly Breaks

Storing valid_from as a bare date or a local timestamp works fine in a demo and fails the first time a price change lands near midnight in a customer's time zone, a daylight-saving transition shifts an hour, or your app server and database default to different zones. The fix is unglamorous but non-negotiable: store every temporal column as UTC with an explicit offset (TIMESTAMPTZ, not TIMESTAMP) and convert only at render time.

Common ways this fails in production:

  • A price change is scheduled for "midnight May 15" without a time zone; the server interprets it as its own local midnight, so customers in other regions see the new price hours early or late.
  • Daylight-saving transitions create an hour that either doesn't exist or exists twice, which breaks naive range comparisons around the transition boundary.
  • A batch job recalculates "today's active price" at server midnight instead of each customer's local midnight, producing a different answer depending on where the job happens to run.
  • valid_to is treated as inclusive in one query and exclusive in another, silently double-counting or dropping the boundary instant.

That last point is why the exclusion constraint above uses '[)' — a half-open interval, inclusive of valid_from and exclusive of valid_to. Richard Snodgrass's foundational work on temporal databases recommends half-open intervals because they compose cleanly: one row's valid_to can equal the next row's valid_from with zero overlap and zero gap.

The IANA Time Zone Database, the reference nearly every serious datetime library defers to, exists precisely because "just use UTC" isn't optional advice — it's the only representation that survives DST rules changing out from under you.

Transaction Time vs. Valid Time: The Distinction That Handles Corrections

Valid time and transaction time answer different questions, and they diverge the moment data arrives late or gets corrected: valid time is when a fact was true in the business; transaction time is when your database found out about it. A backdated price correction — entered today for a change that should have taken effect three weeks ago — needs both, or you'll silently rewrite history you were supposed to be preserving.

ColumnMeaning
valid_from / valid_toThe period during which the fact was actually true in the business
recorded_at (transaction time)When this specific row was written or corrected in the database

Say finance notices on August 1st that a price change was entered incorrectly, and the correct amount should have been effective July 1st. If you only track valid time, the correction simply overwrites the July 1st row — and you lose the ability to answer "what did our system believe the price was, as of July 15th, before anyone noticed the mistake."

That question matters for audit trails, for debugging why an invoice generated on July 20th used the wrong number, and for any compliance review that asks not just "what was true" but "what did you know, and when."

Tracking both dimensions at once — valid time and transaction time — is what temporal-database literature calls bitemporal modeling, a term Snodgrass's work popularized and that shows up in most serious treatments of historical data. You don't need full bitemporal tables for every entity; most products get real value from valid time alone. But the moment corrections, disputes, or audits enter the picture, transaction time stops being a nice-to-have.

The Kimball Group's Slowly Changing Dimension (Type 2) pattern in dimensional modeling is the data-warehousing cousin of this same idea: instead of overwriting a dimension row, you insert a new row with its own effective and expiration dates, keeping every prior state queryable. It's the same insight arrived at from a different direction — analytics teams needed historical accuracy for reporting long before most application databases bothered to track it.

It helps to be blunt about what the schema is actually for. The job your data model needs to do isn't "store the current price" — as the Jobs to Be Done framework would put it, the job you're hiring the schema for is to let anyone, including an auditor a year from now, answer "what did we believe, and when did we believe it," on demand. A schema that can only report the present state hasn't actually done that job; it's just kept the lights on.

Key Takeaways

  • Separate three clocks: transaction time (created_at/updated_at), event time (when it really happened), and valid time (the period a fact was true). They answer different questions and none of them substitute for the others.
  • created_at/updated_at alone can't answer historical questions. They tell you when a row changed, not what was true before or after the change.
  • Effective-dated rows — valid_from/valid_to — are the pattern. Close the old row and insert a new one in the same transaction; never overwrite a fact in place.
  • Use half-open intervals and database-level exclusion constraints so ranges never overlap and boundary instants are never double-counted.
  • Store everything in UTC. Time zones and daylight saving are where "it worked in testing" effective-dating schemes quietly fail in production.
  • Transaction time and valid time diverge on corrections. If backdated fixes or audits matter to your business, model both — that's bitemporal modeling.
  • Effective dating is a modeling decision, not an afterthought. Decide it on the ERD, before you write DDL, for any entity whose facts change over time.

Frequently Asked Questions

What's the difference between createdat and an effective date?

created_at records when a database row was inserted — a transaction-time detail about your system. An effective date (valid_from) records when a fact became true in the business, which is often a different moment entirely, especially for scheduled price changes or backdated corrections. Confusing the two means your "history" is actually just an edit log.

How do I model price history in SQL?

Add valid_from and valid_to columns to the price table, insert a new row for every change instead of updating the existing one, and close the previous row's valid_to in the same transaction. Enforce non-overlapping ranges with a range-type exclusion constraint (PostgreSQL's tstzrange with EXCLUDE USING gist) or equivalent application logic so a query for any single instant returns exactly one row.

Should validto be NULL or a far-future date like 9999-12-31?

Either works technically, but NULL meaning "currently in effect" is generally clearer and plays better with range types and exclusion constraints than a sentinel date, which can accidentally get compared or sorted as a real value. Whichever you choose, document it once and apply it consistently across every effective-dated table.

What is bitemporal modeling?

Bitemporal modeling tracks both valid time (when a fact was true in the business) and transaction time (when the database learned about it) on the same record. It matters when corrections, backdating, or audits need to distinguish "what was actually true" from "what we believed was true at a given point in the past" — a distinction Richard Snodgrass's temporal-database research formalized.

Do I need effective dating if my prices rarely change?

If a price, plan, or contract term can ever change and you might need to answer "what applied on date X" — for a billing dispute, an audit, or a customer support question — you need it, regardless of how rarely changes happen. Rare changes are actually the riskier case: infrequent updates mean the pattern isn't exercised often, so gaps in it go unnoticed until the one dispute where it matters.