SQL for Smarties | SQL Programming Style | Trees and Hierarchies in SQL | SQL Puzzles and Answers | Data and Databases


Tuesday, April 18, 2006

how many joins is too many

SQL Apprentice Question
Does anyone have any good sources of information that talk about how many
joins is too many? I've heard the number 4 or 5 thrown around but haven't
found any 'evidence' to back them up.

Celko Answers

>> I've heard the number 4 or 5 thrown around but haven't found any 'evidence' to back them up. <<


The "Rule of Five" first came from a psychologist named Brown. The
idea is that huymans have a hard time with more than five distinctions
in an input (i.e. if I ask you to rank a movie, food, etc. on a 1-5
scale, you will tend to produce the same results next week. But if I
give you a 1-10 scale, you will not repeat the same answers next week.
This shows up in matching colors, taste, tones, phrases, grid patterns
and a ton of other things.

Fewer than five distinctions is better; more than seven is nearly
impossible. just for fun, look at the combinations 1 items =1, 2
items = 2!, .but .5! = 120 possible ways to arrange the items.


This was quoted in a Yourdon book back in the early days of Software
Engineering.


Now, we have a wonderful mental tool called "Chunking"; in SQL it is
views, CTEs, and derived tables. We take several things and aggregate
them into a new "single unit" until you get to five or fewer chunks.

No comments: