May 27 2010

Everything About Shortcut Joins

Categories: Join Techniques, Universe Design Dave Rathbun @ 6:30 am

There have been a number of posts recently in the Semantic Layer forum on BOB about shortcut joins. When will they be used? How many can be used? Why won’t this particular shortcut get used? Do I have to add shortcuts to contexts? Lots of questions.

I am going to try to clear up a couple of those questions now. First here is a summary of everything I need to know about shortcuts:

  • Shortcut joins do not provide an alternate path.
  • Shortcut joins do provide a shorter path.

By the end of this post I hope that the reader will understand the difference between those two statements. There are two rules for how and when a shortcut will be applied:

  • A shortcut join will only be used if it eliminates tables from the query.
  • A shortcut join is applied after the SQL has been generated (meaning after a context selection has been made, if required).

I will talk about these two items as well. But first, how do I create a shortcut join in my universe?

Creating a Shortcut Join

Creating a shortcut join is quite simple. All I have to do is double-click the particular join and mark the shortcut attribute.

screenshot of setting up a shortcut join

A shortcut join will appear in my universe structure as a dotted rather than a solid line, as shown here.

screenshot of a shortcut join

The process used to create a shortcut join is quite simple. But was it appropriate to convert the join as shown above into a shortcut? Will it be used?

Shortcut Path

The sample shown above is from the Prestige Motors database. There is a direct relationship from the Country table to the Region table, and also from the Region table to the Client table. However there is also a direct relationship from the Country table to the Client table, as the COUNTRY_ID column has been denormalized into the Client record. (If you have never seen this database, a client is a customer.) The question at this point becomes, “Is this a shorter path or an alternate path?”

How do I tell the difference?

I believe the answer is simple. If I get the same result from both join paths then it’s a shortcut. If I get a different answer then it’s an alternate path.

Alternate Path

In the Prestige Motors database the COUNTRY_ID exists in the Showroom table as well as the Client and Region tables. I could create joins like this:

screenshot of the showroom join in the motors universe

In this case I have a join from Country to Client. I also have a join from Country to Showroom. Because of the relationship with the Sales table I now have a loop in my structure. By changing one of the two Country joins to a shortcut I can avoid the loop, like this:

screenshot of the shortcut join to the showroom table

What has happened here? I have eliminated the loop from my structure and solved that problem, right? Perhaps, but it is the wrong solution. In this case, the shortcut is an alternate path rather than a shorter path. I can tell because (as I mentioned earlier) I will not get the same results from the two queries.

Suppose I want to combine Country, Showroom, and Sales. The longer path looks like this:

screenshot of the longer join path

When I execute a query using this set of joins, I will get a list of showrooms that have had sales to customers, and I will get the country where the customer is located. Next I will run a query against this shorter path:

screenshot of the shorter join path

When I execute a query using this path, I will get a completely different result set. I will get a list of showrooms, their sales, and the country where they are located. The customer tables never come into play, so I get a completely different result set. This is my indication that I do not have a proper shortcut join definition.

And interestingly enough, Web Intelligence will never use the shortcut for the query outlined above! It is smart enough to realize that the shortcut is not properly defined as it does not truly present a shorter path. It is an alternate path, and that’s not a valid application of a shortcut.

As a brief aside: How should this particular loop be resolved? Obviously a shortcut is not the answer.

48 Responses to “Everything About Shortcut Joins”

  1. Comment by Andreas

    Great post, Dave, keep the good work up, please!

  2. Comment by Bill Ritchotte

    That was a very informative post. Thanks

  3. Comment by Sharan

    Hi Dave, thanks for this wonderful post, very useful.

  4. Comment by Dave Rathbun

    Thanks, folks, this one took a while to pull together, so I’m glad y’all appreciate it.

  5. Comment by Tanisha

    Thanks Dave!!
    Its pretty informative.

  6. Comment by kay

    Dave, there is never a post from you we don’t appreciate

  7. Comment by Ashley Burton

    Great post, I must say that I’ve always found it a bit sketchy working out if a shortcut join would actually be used though from your post I think I have been using them correctly so far. In this case, would the join you’ve demonstrated be a good way to help get a cascading prompt for Showroom by country without having to have a second context?

  8. Comment by Sriraman

    Dave,
    Great post and excellent work. After reading this post one can clearly understand the difference between normal and shortcut join.
    You blog makes me interested in BO career.
    Thanks

  9. Comment by Preeti Jha

    Great post..keep up the good work!!

  10. Comment by Nniravv

    Great Post, DAVE !!
    Thanks for sharing..
    Can you please cover Contexts and Aliases also with such details?

    Thanks
    Nirav

  11. Comment by Dave Rathbun

    Nniraw, there are a number of posts already available on my blog that cover contexts and aliases. The most summarized version is Context Versus Alias Overview which was part of a presentation from 2008.

  12. Comment by Gary Cronin

    Great post Dave. Very informative.

  13. Comment by Gaurav Singh

    Great post Dave.
    But If in your query you only need something from Country, Showroom and Sales then shortcut join does give you the information you need. If you want to include client then its will take the longer path. Doesn’t it also depends how you define your query?
    Also is it a good idea to join dimension tables with shortcut join all the time?

    Thanks in advance.

  14. Comment by Prasanth

    Hi Dave,

    Perfect post …Wish to be your Student …

    Regards
    Prashant

  15. Comment by Vrushank Patel

    Thanks !! Thanks !! for such a wonderful post

    Regards,
    Vrushank

  16. Comment by Rig

    Hi Dave,

    I deeply appreciate the amount of painstaking efforts that you put to make each of your posts so thoroughly detailed and yet the easiest to undestand.

    Many Many Thanks!!
    Rig :)

  17. Comment by Arya Majumdar

    Thanks Dave.

  18. Comment by Prashant Sahay

    Fantastic Work Dave!!.. I am delighted the way you explain the concepts… Hats off to you… Please keep continuing… Do explain the concepts of incompatibilitis… when it comes into picture… what to keep in mind when objects are incompatible..etc

    Thanks a ton!!

    Prashant

  19. Comment by Tom

    Dave. Could you direct me where to find a copy of the Prestige Motors database and maybe the universe you base your example??
    Thank you.

  20. Comment by Dave Rathbun

    Prestige Motors is (or at least was) used for the Universe Designer training course. The course materials come with the database so that you can work on the problems at home later.

  21. Comment by Tom

    believe it or not I am taking the eLearning version of that course now (BOU315), but I can’t get access to the materials. I did sent an email to their help desk and the person answering said that she did not know where to get this DB or universe file. Would you know of anyone at SAP BI that I could ask for the materials.

  22. Comment by Dave Rathbun

    I expect it would need to be someone in the education or training department. I don’t have any experience with the eLearning versions of these courses.

  23. Comment by Andreas (Xeradox)

    Try contacting: Training@SAP.Com directly

  24. Comment by Tom

    Training@SAP.Com did not work.

    I called their support number and they said that if I was to get their instructor based class then I would get the DB materials.
    I don’t get what is the big deal about this freaking DB. Especially when the course (BOU315) cost $1300. The other courses I got from them work with the eFashion DB that was not a problem to find.

    Anyway thanks for your help.

  25. Comment by Karthik NS

    Great Post. I am an Business Objects administrator and I dont understand anything about Universe Development. By going through your post I am getting to understand the concepts of Universe Design.

  26. Comment by edpypf

    Great Post, Dave! Thank you!!

  27. Comment by Matt

    It seems odd to have Successive as the default for this setting. I have a similar situation to the example shown and this must be common.
    I also found that the choice of which join is the shortcut can also change the behaviour. It seems that the standard join path needs to follow the hierarchy through successive 1-N joins. In the example the standard joins could have been set from the fact table to region, state and outlet with shortcuts from outlet to region and state. This leads BO to choose the ‘wrong’ joins and include the fact table when you just need a list of outlets.

  28. Comment by Dave Rathbun

    Matt, your scenario should never occur. My general rule is that a universe should work perfectly before any shortcuts are added. That means the join path you described should never occur because the universe doesn’t workout the join from outlet to region.

    The reason for the setting is at least in theory to avoid cartesian product joins. However I tend to agree that the choice is unfortunate.

  29. Comment by Matt

    Thanks for highlighting the cartesian problem. I found that the Global setting was giving unwanted (and unexpected) cartesians so I have gone back to the Successive setting and introduced a RegionState entity and then joined that to the Outlet and ShopFacts table. The join to the ShopFacts becomes the shortcut join and everything works as required.

  30. Comment by John

    Hi Dave,

    Would it be possible to share a copy of the Prestige Motors database as well please?

    Thanks,
    John

  31. Comment by Dave Rathbun

    I cannot share the Motors database as it’s used (or formerly was used) for the Designer training course. If you attended the course (or taught the course as I did) then you got a copy of the database.

    I just happened to use it to demonstrate this particular concept.

  32. Comment by sandy

    Very informative and knowledgeable post. Thanks Dave keep up the good work.

  33. Comment by Aaron Reese

    What concerns me more is that you have the fields available to create a shortcut on Client. By denormalising this field you are now relying on application logic or db constraints to ensure that Client.CountryID matches Region.CountryID where Client.RegionID = Region.RegionID. If this referential integrity is broken, then the shortcut will give you the wrong (or at least different because who is to say it is wrong..) results to the ‘proper’ join How would the universe determine whether the shortcut changes the actual results set rather than just eliminating intermediate tables. I suppose the Fault – in the most generous meaning of the word – would lie with the universe designer for either not clarifying the reasons and constraints on the denormalisation or not providing aliases for the country table (1 for use with client and 1 for use with showrooms).

    As an aside, using the original joins, it would be possible to identify clients who have purchased vehicles from outside their country, an acitivity which is quite common in Europe as different tax rates apply.

  34. Comment by swetha

    very informative post.
    my doubt being:

    what is the use of short cut joins?
    will there be any performance improvement if short cut joins used?
    how to say the query/webi to use the short cut join?
    when do we need to use short cut join?

    regards,
    swetha

  35. Comment by Dave Rathbun

    I think most of those questions are already answered in the post, are they not? Certainly the first one is. The improvement comes from the fact that fewer tables are included in the query so the database does less I/O. You as a user don’t force Webi to use a shortcut join, it makes that determination automatically. And you never need to use a shortcut join. You should always be able to get the answer going the longer route, a shortcut is just for convenience and performance.

  36. Comment by wasif

    Hey Dave I am currently working on this universe and was wondering if there is another book for webi based on the same database so I can have better understanding of the report since my universe is based on the motors logic. If there is plz refer .

  37. Comment by Dave Rathbun

    The Motors database comes with (or used to) the standard SAP training material. It’s not likely that there will be any 3rd party books that use this universe since they don’t have the rights to republish it.

  38. Comment by Nisha Prasad

    Hi Dave,

    This post defines the perfect ways to the concept of shortcut joins . It amazingly defined and expalined to be remembered always.

  39. Comment by Ganesh

    Very elaborate information. Showing a good example where a user can understand very easily. Simply U R Gr8.

  40. Comment by Vinod

    Hi Dave,

    I tried to implement the shortcut join in Island Resorts universe between the Sales and Invoice_Line tables but to no avail. Query generator is not recognizing the (only)shortcut join and several tables are being included in the query, even though i have taken only two objects Year and Number of guests. I had also removed the additional tables included in the object properties.
    Please resolve my issue.

  41. Comment by Dave Rathbun

    The question is, why are you trying to use a shortcut between Sales and Invoice Line? That join is not a candidate for a shortcut.

  42. Comment by vinod

    Hi Dave,
    To get the Number of guests based on Year dimension.

    Year Number of guests
    FY2004 10,947
    FY2005 11,364
    FY2006 12,432

    The query generated for the above result is:

    SELECT
    ‘FY’+Format(Sales.invoice_date,’YYYY’),
    sum(Invoice_Line.nb_guests)
    FROM
    Sales,
    Invoice_Line,
    Service_Line,
    Service,
    Reservation_Line,
    Reservations,
    Customer
    WHERE
    ( Customer.cust_id=Sales.cust_id )
    AND ( Invoice_Line.service_id=Service.service_id )
    AND ( Service.sl_id=Service_Line.sl_id )
    AND ( Customer.cust_id=Reservations.cust_id )
    AND ( Reservation_Line.res_id=Reservations.res_id )
    AND ( Reservation_Line.service_id=Service.service_id )
    AND ( Service_Line.service_line = ‘Accommodation’ )
    GROUP BY
    ‘FY’+Format(Sales.invoice_date,’YYYY’)

    so my question is that, can’t we remove the intermediary tables from the above query using shortcut join.

  43. Comment by Dave Rathbun

    Your query is using both sides of the loop (invoices and reservations). There is something wrong with your universe.

  44. Comment by Kevin

    what is impact if I use shortcut joins every where in universe instead of normal join?

  45. Comment by Dave Rathbun

    Simple answer: don’t do it. :) It’s certainly not an appropriate design technique, and I have no idea how the SQL would be generated.

  46. Comment by Mumtaz

    Hi Dave… Very useful post.
    I understand that every join must exist in at least one context. Do we also put short cut joins in contexts or leave them as neutral join (I am considering IDT in stead of Designer)?

  47. Comment by Dave Rathbun

    I have not thoroughly tested this, but my general practice from UDT was to leave shortcut joins out of a context. Shortcut selection should not result in a different context as it could then generate an infinite loop…

  48. Comment by Tulasi

    Gracefully explained!!

Leave a Reply

If you want to include formulas or code in your comment, please read my Tips for formatting comments first. Tags you can use are listed below.

XHTML: You can use these tags: <a href="" title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strike> <strong> <sup> <sub> <u>

Confirm submission by clicking only the marked checkbox:

             *

Please remember that comments that are not related to this blog post may be ignored or deleted without notice. If you're looking for help on a topic you have already posted on BOB then please do not repost your question here.