Differences between Data Sources

0
Hello everyone,   I am currently trying to find out when to use the “Data Source” “Database” and when to use “Association” in a “Data grid 2”.   I sometimes have “Page Parameters” and can also use it to display the existing “Associations” and select the entities linked to them.   However, I can also select the “Association” as the “Data Source” and do the same.   The results look identical.   Then I read the following in the documentation: Sorting columns and searching is not possible in data containers with an association data source. This is because these features require a database call to function, which an association data source does not necessarily initiate.   This confuses me, because if I select an “Association” as “Data Source”, I can still sort and search in my “Data grid 2”.   Then I read that if I select “Association” as the “Data Source”, the results come from the working memory. Can there be problems with this? If I have an account that is linked to projects and the projects are linked to documents, do I only have to query the account once via “Database” and can then only work with “Associations”? Will all the account information then be loaded into the working memory?   Then I also read in the forum that “Associations” helps to keep the database clean when creating objects in case users cancel actions, as they are then not directly committed to the database.   As you can imagine, I am now very confused and would simply always prefer “Association” as “Data Source”. But it can't be that simple!   Or can someone explain to me exactly what the differences are and when I should use which source?   Thanks! Dennis
asked
1 answers
1

The information on 'Sorting and Searching' via DataSource Association is a bit misleading/outdated for DG 2.

DG 2 supports sorting/searching in the client even for data that is not fetched via DB calls. Older widgets did not offer that functionality.

The 'retrieve from memory' for association data sources is actually a bit more complex, since it behaves slightly differently depending on context and type of data. I think this documentation gives a good overview: https://docs.mendix.com/refguide/datasource-runtime/

 

A lot really depends on how you design your application, but quite generally

* if your data is already commited, or directly commited after edit -> database

* if you work with non-commited, temporary data or changes -> association

 

answered