News for hackers. Stuff that matters.
Re:Postgres 15 improves UNIQUE and NULL by jhugo on Monday July 11, 2022 @10:55PM (#32065033)
Such "tables" would more typically be constructed as views (materialised if performance requires it) over underlying data. In this case the underlying data would have a row for each sale, with a normal nullable column for agent_id. The query that constructs the view would use GROUP BY, and since NULLs group together in GROUP BY it would work as you expect (grouping "no agent" sales together into a single record in the view). The database system thus handles ensuring data consistency, merely by using its features as they are designed to be used.

There are no comments on this comment yet.