3 ms·
The lost art of normalizing databases. ”Why is the ARR so high on client X? Oh, we’re counting it 11 times lol”. I would maybe throw in date as an key too. Bad
by estetlinus 6mo ago
The lost art of normalizing databases. ”Why is the ARR so high on client X? Oh, we’re counting it 11 times lol”.
I would maybe throw in date as an key too. Bad idea?
- petalmind 6mo agoFrankly I don't think that overcounting is solved by normalizing, because it's easy to write an overcounting SQL query over perfectly normalized data. I tried to explain the real cause of overcounting in my "Modern Guide to SQL JOINs": https://kb.databasedesignbook.com/posts/sql-joins/#understanding-the-problem-of-overcounting https://kb.databasedesignbook.com/posts/sql-joins/#understan...
- estetlinus 6mo agoGreat read, thank you!
- mickeyp 6mo agoI'll go one further and say that if you're reaching for DISTINCT and you have joins, you may have joined the data the wrong way. It's not a RULE, but it's ALWAYS a 'smell' when I see a query that uses DISTINCT to shove away duplicate matches. I always add a comment for the exceptions.
- hilariously 6mo agoIt depends on if you are doing OLTP (granular, transactional) vs OLAP (fact/date based aggregates) - dates are generally not something you'd consider in a fully normalized flow to uniqify records.
- estetlinus 6mo agoMakes sense. I’m an OLAP guy.
- hilariously 6mo agoWell you are in luck, if someone tells your to normalize you can tell them their source system can fuck right off.