BusinessObjects Board

Use of Cardinality

Hello All,

I am not understanding the role of Cardinality,
As far as i know Cardinality is a property of a join that describes how many rows in one table match rows in another table and The cardinality of a join does not have a role in the SQL generated when We run a query.

And i also read somewhere that Designer uses cardinalities to determine contexts and valid query paths.

So i am not getting what role cardinality plays here because its we who create the context and add the joins to the context, what designer does over here??

Any help will be appreciated


vicky1 (BOB member since 2010-10-20)

What are the consequences if i give a wrong cardinality because it is not involved in the sql creation part?


vicky1 (BOB member since 2010-10-20)

Start with the link (an old discussion but a valuable one)


jprasanthram :switzerland: (BOB member since 2010-12-10)

I went through the link but I got confused more :frowning:

I have two questions in mind
1)How does the designer use Cardinality to determine contexts and valid query paths. What relation does cardinality have with context?
2)If i give a wrong cardinality there will be no effect on my SQL created so why is this feature?


vicky1 (BOB member since 2010-10-20)

Use of cardinality is to understand the business purpose and to better understand the data model and it helps the other developers after you to understand.

if you specify it incorrectly its not going to affect the SQL or the report.


jprasanthram :switzerland: (BOB member since 2010-12-10)

Correct whatever you told does make sense and even i was having the same impression but when i was looking to designer guide it is written that “Designer uses cardinalities to determine contexts and valid query paths”

I am not understanding this part


vicky1 (BOB member since 2010-10-20)

Have you read about chasm and fan traps yet?

Hello Mark,

Yes i have gone through that
Fan trap (serial many to
one joins)
Chasm trap (converging
many to one joins)

But y are you asking this ?


vicky1 (BOB member since 2010-10-20)

It’s because the two are related.

You set your cardinalities to allow Designer to know which context(s) joins should belong to. When detecting contexts, Designer finds all tables that have only many joins going into them (typically all your fact tables in a multi-star schema). The algorithm then “chases out” the many joins along paths to find all the joins it needs for each context

So A -< B -< C >- D -- F

would cause Designer to initially find tables C and E as the starting points.
The context for table C would find the joins C-D, C-B and B-A, while the context for table E would find the joins E-F and E-D. That’s because you’ve set the cardinalities correctly; Designer doesn’t know for itself what the cardinalities are and detect cardinalities typically gets a fair few wrong so don’t use that, use the schema.

Regards,
Mark

Hello Mark,

I am little bit new to universe designing so there may be i ask some stupid questions please bare with me :slight_smile:

Actually i am creating a join and then manually(Right click add to context) adding it into the previously created contexts based on my model.
So In this scenario does still cardinality plays a role


vicky1 (BOB member since 2010-10-20)

Besides all what was said above, setting cardinalities right in a universe helps universe developer to visually check the universe and to find potential chasm and/or fan traps.

Without cardinalities being set, every table looks more or less the same and it’s difficult if not even impossible at all to tell where there could be a chasm/fan trap.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

With reference to your experience, how do you know which context(s) to add joins to?

Hello mark,

Actually i have four fact tables and multiple dimension tables and corresponding to ever fact table i have a context for example if i have a daily fact table i have a context called day and i add all those joins from the daily table to any dimension table in the context day.
That’s how i am currently working, i dont know whether its a correct approach or not but seems to be working.
So is it that i am manually doing all this things instead of relying on designer i am not able to find the importance of cardinality??


vicky1 (BOB member since 2010-10-20)

Agreed, i think this is the main purpose .To improve the visualization and as cardinality does not play a role in sql generation also.


vicky1 (BOB member since 2010-10-20)

Vicky,

As Mark has said, cardinalities are needed for the generation of the relevant Contexts. So why don’t you have Designer auto-generate the Contexts rather than doing it manually; it’s far quicker and more reliable. Others may disagree, but in 15 years I have very, very rarely (if ever) needed to manually modify / generate Contexts. Auto-generation should be your default.


anorak :uk: (BOB member since 2002-09-13)

Hello Anorak,

So what i understood was cardinality plays a role in identifying fan traps and chasm traps by improving the visualization.
Cardinality also play a role in suggesting the context if you are using the designers default feature of context suggestion.

Please rectify me if i am wrong somewhere and please do add if you think cardinality also play any other role


vicky1 (BOB member since 2010-10-20)

Vicky,

I’m being being a bit pedantic, but chasm and fan traps are identified through an analysis of the cardinalities that have been defined when the joins are created, not through visualisation.

Also, I would say that ‘context suggestion’ is an understatement; ‘context definition’ being more appropriate. i.e. you would have to have very particular (and rare) reasons for changing the contexts from those automatically defined.


anorak :uk: (BOB member since 2002-09-13)

Ya thanks anorak, got it :slight_smile:


vicky1 (BOB member since 2010-10-20)

Hi Anorak,

How do we determine whether we have to use an alias or a context to resolve a loop? I have 3 dim tables (A,B,C)and 1 fact table (D).

A is joined to B
A is joined to D
B is joined to C
C is joined to D

I think that as the dim table A is used twice, I should create an alias.

Also in a context, do we need to have min 2 joins atleast as it is collection of joins?

Thanks


gu.rashmi (BOB member since 2011-06-09)

[quote:377b1becd7=“gu.rashmi”]A is joined to B
A is joined to D
B is joined to C
C is joined to D

I think that as the dim table A is used twice, I should create an alias.
[/quote]
When you draw it on a paper you could see that every table is used twice (every table is joined to 2 other tables). :slight_smile:
So whether some table is aliased or more contexts are needed depends on the purpose of the tables and on the cardinalities of joins between them.
From what you wrote (A, B, C are dimension tables) - it looks to me that any of these tables could be aliased. But it really depends on the purpose of tables. Does one of the A, B, C tables play more “roles”? Like a date dimension can play 1st role as an order date and 2nd role as a shipment date.

[quote:377b1becd7=“gu.rashmi”]Also in a context, do we need to have min 2 joins atleast as it is collection of joins?
[/quote]
You can have a context with just one join. :slight_smile:


Marek Chladny :slovakia: (BOB member since 2003-11-27)