How to display information from two related tables in mendix

0
I have two tables in the database. how can i display the data of both the tables based on a join on the common column or search field. eg: Table A has (Name,email) , Table B has (Postcode,Area) I would like to know how i can achieve this in mendix. Any help/pointers is highly appreciated as i'm new to Mendix. Thanks.
asked
1 answers
4

Prathibha,

In Mendix, you accomplish this via associations. Associations are similar to joins but have some important differences. The most important is that you don't need a join column in Mendix as you would in an SQL database. Associations are populated either programatically (via a microflow) or via the user interface using entry screens.

In the domain model you describe, lets call Table A Person and Table B Address. Assuming a Person can have more than one address, you would then have a one to many association between Person and Address. You could draw this in the domain model by dragging an arrow from Address to Person, or you could define it inside of the edit window for the Person entity in your domain model - look for the Associations table. Then you could create four web pages:

  • A listing page for Person - using a datagrid
  • An entry/edit page for Person - using a dataview
  • A listing page for Address - using a datagrid
  • An entry/edit page for Address - using a dataview

In the listing page for Address, you can display the Person associated with each address via the association. Also, to populate this information, make sure you put a reference selector on your entry/edit page for Address pointing to the association you created.

Hope that helps you get started. BTW, the Pizza Mario app has good examples of all of this (not sure if it is available for version 5 or not, but if not, the Employee Directory app in the App store will have examples too). Also, the online training course that was recently released covers all of this, Sections 5 and 7 in particular. You can access that course in the Getting Started section of the App Platform.

Mike

answered