ACM Editorial · 2026-11-28 · 1 min read

Use separate tables for repeating relationships, such as invoice items and client contacts.

Design for the data lifecycle

Use separate tables for repeating relationships, such as invoice items and client contacts. Define data types and constraints according to the actual meaning of each field. Store money in exact numeric representations rather than binary floating point.

Choose indexes from queries

Index commonly filtered foreign keys and date ranges. Composite index order matters; match it to the predicates used by a query. Excess indexes increase write cost, so inspect execution plans and measure before adding them.

Protect concurrent writes

Wrap multi-step changes in transactions. For a payment that reduces outstanding balance, lock or otherwise protect the invoice while checking the current amount. A check made before the transaction can become stale.

Plan backups and upgrades

Test restoring a database into an isolated environment and compare record counts and balances. Keep migration scripts under version control, and review locking behaviour for changes on large tables.

Further reading

https://www.postgresql.org/docs/