Data Model Best Practices

Stimulsoft Reports.JS discussion
Post Reply
du8die
Posts: 4
Joined: Wed May 13, 2020 1:17 am

Data Model Best Practices

Post by du8die »

Hi,

I started using the demo version of the Reports.JS library yesterday - and so far, by and large, I love it. I was easily able to add complex reporting functionality to my app. I'm very much excited about continuing to work with the library and see what all I can do with it. I do have a few questions - and they are around best practices for data models.

1) I currently am using a single data set for my data model. It is based on an AdHoc query engine I wrote. This ad-hoc query engine is such that the source data is purposely full of cartesian products - which are then filtered out on display. I was able to get the library up and running very quickly using this process. However, I am not finding a way that I can restrict the output to only show unique data (based on the fields used in the report)?

For example:

Code: Select all

Last Name          | First Name          | Movie                                           | Award
-------------------------------------------------------------------------------------------------------------------------------------------------
Mouse              | Mickey              | Steamboat Willie                                | Oscar Nomination
Mouse              | Mickey              | Steamboat Willie                                | Oscar (Best Animated Short)
Mouse              | Mickey              | Jack and the Beanstalk                          | Oscar Nomination
If I were to create a report with only the Last Name, First Name and Award Columns in it, I want to see

Code: Select all

Last Name          | First Name          | Award
-------------------------------------------------------------------------------------------------------------------------------------------------
Mouse              | Mickey              | Oscar Nomination
Mouse              | Mickey              | Oscar (Best Animated Short)
I currently see:

Code: Select all

Last Name          | First Name          | Award
-------------------------------------------------------------------------------------------------------------------------------------------------
Mouse              | Mickey              | Oscar Nomination
Mouse              | Mickey              | Oscar (Best Animated Short)
Mouse              | Mickey              | Oscar Nomination
------------------------------------------------------------------------------------------------------------------
My data source is JSON - and it is served from a REST API. I would much prefer to split the data apart into its component pieces - and set up the pulls from the database that way. In the long run, I suspect that will be much more efficient.

However, I am not finding any documentation on setting up datasets - particularly when it comes to relationships between them. I need to do this in code (vanilla JS) - (I'm on a .NET platform - but I would prefer not to use the .NET controls). How does one go about defining two related datasets in the JavaScript code? I can define them separately - but I'd like to also define the relationships.

Third - Currently, I am loading a sample dataset and letting the tool figure out the Schema. This is fine - but it's not user friendly. Is there a way for me to define the schema up front - and then pump in the data later? This will reduce the need for things like "root" being all over the place.

Thanks - if any of this isn't clear - please let me know. I'll do my best to clarify!

d8
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: Data Model Best Practices

Post by Lech Kulikowski »

Hello,

You can use DataRelations to relate data sources:
https://www.stimulsoft.com/en/documenta ... operty.htm

Also, you can find samples on our Demo in the "Master-Detail Reports" category:
https://demo.stimulsoft.com/#Net/MasterDetail

> Third - Currently, I am loading a sample dataset and letting the tool figure out the Schema. This is fine - but it's not user friendly. Is there a way for me to define the schema up front - and then pump in the data later? This will reduce the need for things like "root" being all over the place.

You can provide an empty dataset without data:
https://www.stimulsoft.com/en/documenta ... _files.htm

Thank you.
Post Reply