A one-to-many relationship, often referred to as a "master-details" or "parent-child" relationship, is the most usual relationship between two tables in a database. Common examples of this relationship include customer/purchase data, patient/medical-record data, and student/course-result data.
For example, each customer (Master table Customers) is associated with at least one order record (Details table Orders). Valued customers have several order records and often a user needs to view one table in connection with the other.
Master-details relationships are commonly used in applications. In PHPRunner, you can join or link several tables that have at least one common field. You can Add/Edit the records of the linked tables on the same page in the generated app.
Here is an example of a Master-details relationship between the Carsmake and Carsmodels tables, where the details table shows the models for the selected make.
To create a master-details relationship in PHPRunner:
1. Go to the Datasource tables screen and enable the tables you wish to link in the left panel.
2. Drag a field from one table to another.
The Table link properties dialog opens. The options are described below.
3. Choose which table is the Master one and select the link fields for both tables.
4. Set up the Master and Details settings. If you'd like to display the master table data on the details page, select the corresponding checkboxes. Click OK.
5. The master-details relationship is created and displayed as an arrow between the tables.
Here is how the Table Link Properties window looks like:
Here are some of the examples for the Table Link Properties options:
Show single link for all details:
A link for details is displayed as icon. Click it to view the details tables. Use this option if the master table has multiple details tables.
Show individual details links:
Preview details records in popup:
Preview details records inline:
If you select to display the details records inline, you can add/edit/delete the details in an inline mode on the master table page.
This option allows you to hide the details preview on the master table View/Add/Edit page if the details table does not contain any records for the current master table record.
Display master table data on the details page:
If a master table has two or more details tables, you can re-order the details tables as well as choose the orientation (vertical or horizontal). You can do that in Page Designer.
Here is an example of a "customers" table that has two details tables: "referrers" and "orders".
Proceed to the Page Designer to change the order of the details tables using drag-n-drop:
You can print the master table data on the List page with the data from the details tables. Click the Print icon and select the corresponding checkboxes to do so.
Here is an example of a page to be printed:
A chart as a details table:
A chart as a master table:
A report as a details table: