Question
· Apr 13, 2019

In cube, one way relationship for a one to many class relationship

I am building a cube based on a source class, which I  will call,  Family.Dad 

In the class definition for Family.Dad, there is a relationship, offspring  As Child  [ Cardinality = children, Inverse =  father]

In the class definition for Child, there is a relationship called father As Dad  [ Cardinality = parent, Inverse =  offspring]

In the actual data, a dad can have many children, but a child can only have 1 dad.

Using DeepSee, I am trying to analyze to answer questions such as how many dads have children called Joseph ( Ex dad.offspring.GetAt(x).Name) etc . 

The only way I was able to do this was by setting up a relationship in the dad cube and its inverse in the kids cube. In the dads cube, the relationship is called Kids. Kids has a cardinality of many, inverse is Dad and the related cube is the KidsCube.

The KidsCube has a relationship called  Dad, property is Dad.%ID, cardinality is 1 , related cube is Dad cube. Not only is this slowing down the analyzer, it is also creating an extra copy of the dad's dimensions in the dad's analyzer !!!  I see the dimensions of the kids cube but right below them, I see the dimensions of the dad , under a branch called "Dad". Ofcourse below that is another copy of Kids and this goes on and and on for as long as I keep clicking

My question is how do I show the dimensions of the kids in the dads cube without making multiple copies of the dads records? I think the issue comes down to this. How do you show the dimensions of a child cube in the parent cube when its a one to many relationship (1 parent,man children).I was able to set up a one directional relationship in the Kids cube to the Dads dimension and there was no duplication . This  was a many to one relationship so the source property was Dad.%ID . But this is not what I need! I need to see this from the dad's view!! Hope this makes sense!!

Discussion (6)1
Log in or sign up to continue

Hi Stella!

This is complicated cause the base class of a cube should contain the most granular records for the subject area being analyzed. Speaking with family terms children can analyze their dads in a cube but not vice versa.  That means want to analyze Kids - build the cube for Kids.

There is one trick though which lets you analyze Kids from Dads assuming if your Dad is not very fruitful ;) I mean this will work if your Dad has less then 1,000 kids) 

You can build the Kids dimension with a level which consists of a comma-separated list of Kids IDs or kids data - use ObjectScript expressions for this. And mark this dimension as comma-separated in Dimension settings.

If the ObjectScript expression is long, use %cube.Method to call the method of the cube where you can code the complex logic.

Then you are able to show in levels and properties in this dimension whatever data you want to calculate and aggregate from kids using ObjectScript expressions.

HTH