|
|
|
|
|
by sitharus
530 days ago
|
|
This is where the foundation of a relational database semantics in set theory shows through. You can’t model the behaviour with pure boolean logic. In the SQL spec by default unique indexes consider nulls distinct because you’re adding tuple to the relation, and this is done by equality. When doing a select distinct or group by you’re not doing a boolean grouping, you’re doing a set projection. NULLs are considered part of the set of “unknown values”, so NULLs are grouped together but they’re still not equal to each other. The behaviour is mathematically well defined, but it doesn’t match boolean logic. I’ve been dealing with databases for well over 20 years now and I can only think of a couple of times when this behaviour wasn’t wanted, so I think it’s the right choice. |
|