Preventing Chasm and Fan Traps!

November 18, 2008 by: David Lai

In this article I would like to talk about Chasm traps and Fan traps. These are problems that we often experience while building universes and reports. When encountering these traps, one may wonder what is going on? How come my sum statements arent adding up correctly? Or why am I missing some rows? A properly designed universe will help avoid these problems. In addition, a good understanding about measures and contexts from report designers will help as well.

Chasm Traps

Let’s talk about Chasm traps first. In short, a Chasm trap can be imagined as a bottomless pit where some rows may unknowingly fall in and never come back out. So when viewing a report caught in a Chasm trap, one may ask “Hey where did Record X go??”.

efashion test

Looking at the eFashion Universe (note that this is a modified version of the efashion universe), we see that there are 2 fact tables that join to 2 of the same dimension tables. If we do not set a context for each of the fact tables in the universe, we will only get 1 query when building a report that involves measures from both fact tables.

SELECT
Article_lookup.Article_id,
Shop_facts.Amount_sold
FROM
Article_lookup,
Shop_facts,
product_promotion_facts,
Calendar_year_lookup
WHERE
( product_promotion_facts.Week_id=Calendar_year_lookup.Week_id )
AND ( Article_lookup.Article_id=Shop_facts.Article_id )
AND ( Article_lookup.Article_id=product_promotion_facts.Article_id )
AND ( Shop_facts.Week_id=Calendar_year_lookup.Week_id )

Since the promotion fact table and shop fact table are joined in the same query, we will only get results that are in both the promotion fact and shop fact table. In reality we want all available products even if they are not on promotion. The products that are not on promotion will fall down the bottomless pit and report designers will be wondering where they have gone.

chasm trap

Fan Traps

Fan traps are another common problem and occur when a measure is overstated. So using the same example above, the promotion cost measure is a “sum of promotion costs”. Let’s say for one product we might have 5 entries in the shop fact table and 2 entries in the promotion fact table. Instead of a one-to-many join for the promotion fact table, we now have a many-to-many join which will cause a cartesian product. The promotion cost for that product will be 5 times higher than what its supposed to be since we have 5 entries in the shop fact table.

fan trap

Prevention
To prevent falling into these traps, we must properly set our contexts in the universe. Here we set a context for both the promotion fact and shop fact. As a rule of thumb we should always set contexts for facts.

setting universe contexts

Setting contexts for these 2 facts will now produce 2 queries that will be synchronized thus returning the correct results because now we have 2 seperate joins instead of 2 joins in the same table.

Comments

8 Responses to “Preventing Chasm and Fan Traps!”
  1. Shahid says:

    Its really interesting to see details on two BO Specific challenging issues discussed in detail here. I am also blogging on BI and Data Warehousing. If you feel interested I would like to add you to my blogroll, and would like you to do same, please.

    Shahid.

  2. David Lai says:

    Sounds good
    I will add you to my blogroll

    Thanks!

  3. Sumit says:

    Thanks for this information, this clarify lots of doubts,which i was having.
    Thanks
    Sumit

  4. Blues says:

    Pretty neatly explained.

    Thanks

  5. BJF says:

    This is the best explanation I’ve found so far.

    It seems to me that a FAN TRAP or a CHASM TRAP is not defined by the table relationships. The same set of table joins can cause both a Fan Trap and a Chasm Trap, depending on the query and the nature of the data. The real difference between them is: A Fan Trap causes an incorrect increase of records due to a 1-many relationship. A Chasm Trap causes an incorrect limiting of records due to unneeded tables getting pulled into the joins (because of a context).

    Correct?

  6. David Lai says:

    Yes your explanation says what I was explaining in the article, minus the prevention and example.
    Anyhow, adding to the prevention of Chasm Traps, multiple universes can be used to produce a true star schema so that you avoid messy contexts. You can then connect the universes together at the report level.

  7. annie says:

    This is the best explaination for chasm trap so far!
    Thanks very much for putting this together. I’ve subscribed to you blog today. AT

  8. Raveesh says:

    HI David,

    We can also avoid chasm Traps by choosing multiple sql staements,how it differs with context method…

Leave a Reply to Sumit


× two = 10