Metadata
- Author: Randy from Counting Stuff
- Full Title:: Everyone Fears the Cartesian
- Category:: 🗞️Articles
- Document Tags:: sql, SQL,
- Finished date:: 2023-08-09
Highlights
The problem with such key-value arrays is that they’re intended to be catch-all fields. They’re to put miscellaneous one-off logging data for when it’s not reasonable to modify the schema for. Devs use them as arbitrary-length data stores and can shove as many key-value pairs in as they want, even change the contents of existing fields without notice. Just because a query is well behaved and has a 1-to-1 mapping for joining today doesn’t guarantee that some creative future change won’t break things and turn it into a 1-to-many relationship later. (View Highlight)
As far as I can tell, some variation of this mishap has happened to every single person that regularly uses SQL to report things (View Highlight)
So the backup strategy is to just sidestep the duplicates by counting distinct items instead (View Highlight)