HOME > SUPPORT > RELATIONSHIP FLATTENING

Relationship Flattening

  Overview

One of the most important concepts in ReportMill is that of "Dataset Keys". ReportMill has a number of dataset elements used to display datasets (tables, graphs, crosstabs, labels). Each of these expect a "dataset key" to identify the dataset they should display.

For instance, a simple report using the sample Hollywood dataset might have a table that iterates over all the studios from the given datasource. This table might use the "Studios" dataset key and show one record/table-row for each studio.

Now it's also common for dataset objects to each have a list themselves, in a "master-detail" type construct. In this case, each studio has a list of movies released by that studio. And, in rare cases, you may find that though your application only provides data of a higher level entity, like Studio, you may actually want to run a report on a consolidated dataset of a child entity, like a combined list of each Studio's list of movies.

To handle this, ReportMill has a feature that lets you automatically get a consolidated set of objects derived from a child dataset found in each object of a "master" dataset. In the case of our example, we could run a report on movies by setting the table dataset key to "Studios.getMovies".

Reports Independent of the Master

One of the most important aspects of relationship flattening is that it lets you create reports that are independent of the actual "master". Once we have chose the dataset key "Studios.getMovies", the actual root entity is a Movie. So we can easily show a report of all movies in our dataset grouped by Category and ignore the fact that the movies originally came from a list of studios.

Accessing the Master

Even though relationship flattening effectively gives us a list of the "details" from the master-detail construct, it is often still handy to reference the Master, particularly if the details don't have an explicit back-pointer. This can be done in one of two ways. The first is that you can simply use the prefix of your dataset key. So if the studio has a "getStudioName" attribute, you can reference it with the "Studios.getStudioName" key. Also, ReportMill will recognize a reference to the Master's class, so if each object in Studios is of class Studio, you can also use the key "Studio.getStudioName".