Debugging
After syntax errors cleared up
- Query runs; results wrong
- Join problems
- Know data: count, characterize population
Population defined by WHERE clause
People:
|
10
|
Adresses for people with addresses:
|
13
|
People with adresses:
|
9
|
Addresses of all 10 people:
|
14
|
Population test:
select count(*) "count",
count(distinct name_id) "dist"
from name
where name_seriesno = name_now(name_id);
count dist
----- ----
6 6
Numbers should match
If they don't, step through the joins:
- Add one join at a time
- Test population again
- Join problem located when numbers don't match
Join problems;
- Population loss; "falling through join"
Ex: From 6 to 5 after adding join
- Population gain: "mulplying through a join"
Ex: 6 and 7: one item counted twice
- 5 and 7: both loss and gain
Correction:
- Identify row(s) causing problem
- Compare to join conditions
- Determine cause
Top
References