Escolar Documentos
Profissional Documentos
Cultura Documentos
Generator?
Last modified: Jul 19, 2010
Prev
Abstract
Below is a step-by-step explanation of how to create a master-detail presentation for relationships that
are multivalued in both directions. The information represented in this article describes the usage of PHP
Generators for: MySQL, Microsoft SQL Server, PostgreSQL, Oracle,SQLite, Firebird, IBM DB2, SQL
Anywhere, MaxDB.
Problem
Detail presentations for tables linked by one-to-many relationships are created with PHP
Generator with a couple of clicks. Let's see the implementation of such presentation for two
entities 'employee' and 'office' where one employee can work at more than one office and an
office can have more than one employee assigned (a many-to-many relationship).
In database design, the standard decision of the problem is the breaking of such relationship
into two one-to-many relationships and creating a new (junction/link) table to stand between
junction table
SQL definitions of the tables are as follows:
To see the list of offices and lists of employees assigned to selected offices on one web page,
Solution
• Configuring datasources
Each step will be covered in detail below. To work with the prepared script, you need to have
Step 1
Add the 'office' table as a datasource using the Add table or view button.
Specify a query to be a datasource for the master-detail presentation. For this purpose use
the Create query button and enter the following query text:
Listing 3. Query
SELECT
eo.office_id,
e.*
FROM employee e
INNER JOIN employee_office eo
ON eo.employee_id = e.id
To allow users to insert, update and delete an employee to/from the employee list of the
selected office, check the Updatable query box and set update statements:
UPDATE employee_office
SET employee_id=:id
WHERE employee_id=:OLD_id AND office_id=:OLD_office_id
Step 2
the Add... link of the popup menu. Set up the Detail relation editorproperties: select the
created query as Detail data source, 'id' as Master field and 'office_id' as Detail field.
detail presentation
You can also adjust the appearance of the employee lists (details pages) with the Detail page
editor. We disallowed the content of 'office_id' and 'id' columns to be represented on the