Anda di halaman 1dari 4

Generated by Jive on 2014-05-11+02:00

1
simple example for SQL traps [chasm /...
Swetha N 369 posts since Feb 18, 2010
simple example for SQL traps [chasm / fan trap] May 2, 2012 2:41 PM
hi all,
i already browsed SDN for this topic but got confused soon.

can anyone explain with a very simple example about SQL traps [chasm / fan trap] and the solution for the
same.
Ravi Shankar 692 posts since Jan 20, 2012
Re: simple example for SQL traps [chasm / fan trap] May 4, 2012 11:58 AM
Hi Swetha,

Chasm trap
The Chasm trap occurs when two many to one joins converge on a single table. For example a
customer can place many orders/and or place many loans.
Fan trap

The Fan trap occurs when a one to many join links a table which is in turn linked by another
one to many join.

For example when you run a query that asks for the total orders by each order line, for a
particular customer, an incorrect result is returned as you are performing an aggregate function
on the table at the one end of the join, while still joining to the many end.

Chasm Trap example:

For example:

A >- B -< C

( Employees >-- Showroom --< Salary)

- Each showroom has many employees
- Each showroom has many annual salary figures
The number of employee records should not impact the total salary on the report.

simple example for SQL traps [chasm /...
Generated by Jive on 2014-05-11+02:00
2
If a query is written that spanned all three of those tables the data from table A and C, there would be
duplicated and the measure values would be exaggerated. For example,
- X rows on the left
- Y rows on the right
- X * Y rows in the combined set

Solution 1:
Define a context for each table at the many end of the joins.

Context = Meaning

- A context is a sub-set of joins in a universe
- That sub-set of joins has a particular meaning

In our example you could define a context from A to B and from A to C. A context contains each join in the
path. This creates two SQL statements and two separate tables in Business Objects, avoiding the creation of a
Cartesian product. Using contexts is the most effective way to solve Chasm traps.

Solution 2:
Select the option Multiple SQL Statements for Each Measure from the Universe Parameters
dialog box in the tool. Only applies to measures. You force the SQL generation engine in Reporter
to generate SQL queries for each measure that appears in the Query panel.

Fan Trap example:

For example:

A -< B -< C (Ex: Customer --< Orders --< Order_Lines)

A fan trap is not quite as severe as a chasm trap. In fact there are many fan traps that can occur in a universe
design that can be ignored as long as you control which types of objects you use.

There are two ways to solve a Fan trap problem.

Using an alias and the aggregate awareness function. This is the most effective way to solve
the Fan trap problem.
Altering the SQL parameters for the universe. This only works for measure objects.

Both of these methods are described below.

Solution 1:

simple example for SQL traps [chasm /...
Generated by Jive on 2014-05-11+02:00
3
Aliases can resolve chasm traps

- Known as table aliases when writing SQL statements
- Used by BusinessObjects to logically separate the trap into pieces.

You create an alias table and use the aggregate awareness function. You cannot use this option if you have
incompatible objects. You can do this as follows:

1. Create an alias for the table that is producing the multiplied aggregation.
2. Create a one to one join between the original table and the alias table.
3. Modify the select statement for the columns that are summed so that the columns in the alias table are
summed and not the original table.
4. Apply the @AggregateAware function to the select statement. for example:
@AggregateAware(SUM(ORDERS.TOTAL_VALUE) , SUM(ORDERS_2.TOTAL_VALUE))

Solution 2:
- Create a separate SQL statement per aggregation.
- Aggregations on the same table require only 1 SQL statement.

You select the option Multiple SQL Statements for Each Measure. You force the SQL generation
engine in Reporter to generate separate SQL queries for each measure that appears in the Query
panel. You find this option on the SQL page of the Universe Parameters dialog box in the tool.

Hope this info helps...
Swetha N 369 posts since Feb 18, 2010
Re: simple example for SQL traps [chasm / fan trap] Jun 26, 2012 1:06 PM
thanks for the reply.

those interested to know more, pls refer to Dave's papers on the topics.
very good explanation with examples.
Hitesh Chaudhari 16 posts since Oct 7, 2013
Re: simple example for SQL traps [chasm / fan trap] Oct 26, 2013 10:27 AM
Do you you any example in efashion or club
sapbo bi 3 posts since Oct 25, 2013
Re: simple example for SQL traps [chasm / fan trap] Oct 25, 2013 12:12 PM
simple example for SQL traps [chasm /...
Generated by Jive on 2014-05-11+02:00
4
I was going through Google searched result. and found some interesting links related to FAN trap. hope this
would be interest to all. this site has ready script that you can test on your database to know how and when fan
traps occur.

http://www.bobidw.com/2013/10/business-objects-fan-trap-explained.html
Hitesh Chaudhari 16 posts since Oct 7, 2013
Re: simple example for SQL traps [chasm / fan trap] Oct 26, 2013 10:25 AM
this link doesn't have a solution just a scenario. Can any one illustrate with some data? .
I want to know the result's before and after the application of resolution of fan trap
Hitesh Chaudhari 16 posts since Oct 7, 2013
Re: simple example for SQL traps [chasm / fan trap] Oct 26, 2013 10:26 AM
Chasm Trap best explained here in link
http://www.bidw.org/business-objects/universe-design/sql-traps-in-business-objects-universe-how-to-solve-
chasm-trap/
Scott Leckie 1 posts since May 30, 2013
Re: simple example for SQL traps [chasm / fan trap] Jan 10, 2014 11:29 AM
Thanks. This is a huge help.

Scott.

Anda mungkin juga menyukai