When you have two competing theories that make exactly the same predictions, the simpler one is the better.
Solution: Divide and Conquer
The quote at the beginning of this chapter is similar to the law of parsimony:
What this means to SQL is that when you have a choice between two queries that produce the same result set, choose the simpler one. We should keep this in mind when straightening out instances of this antipattern.
One Step at a Time
If you canât see a logical join condition between the tables involved in an unintended Cartesian product, that could be because there simply is no such condition. To avoid the Cartesian product, you have to split up a Spaghetti Query into several simpler queries.
In the simple ...
Get SQL Antipatterns, Volume 1 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.