The Table Editor

 

The most important part of retrieving information from a database is specifying which tables are being accessed and how they are related. That is the purpose of the Table Editor. You invoke this dialog using the “Edit” button in the “Query Editor.”

 

As shown above, the Table Editor has two main portions. On the left is a tree showing what tables are referenced and how they are related. Also on the left are the controls used to modify the existing information. On the right is the information needed to add new tables to the tree.

Adding tables to the tree

The right side of the Table Editor consists of a table list, some options for controlling the contents of the table list, and the “Add Table” button. Only tables with names beginning with the text in the “Match” field are shown. In addition the “Views”, “Tables”, and “System tables” flags cause the list to show SQL views, ordinary database tables, and tables that have special meaning to the database.

 

To add a table to the tree select it and click then click the “Add Table” button or double click a table in the table list. It is added to the table tree as a child of the currently selected item. WordPage attempts to determine the relationship between the two tables by looking for common column names. If no common names are found you will be taken directly to the Condition Editor to specify the relationship.

Understanding the table tree

The tree on the left of the table editor shows the tables that are currently included and how they relate to each other. For any table other than the topmost parent a condition must be specified that relates the child table to the parent. This relationship is called a “join.” This condition is displayed along with the alias for the table if one exists. The icon to the left of the table name indicates the type of join performed between the parent and child tables. Any problems detected by WordPage are shown in red.

Editing tables in the tree

For the currently selected item in the table tree there are four things you can control. You can remove the table from the tree by clicking the “Delete” button. The condition that joins the parent and child tables is edited using the “Edit Condition” button.

 

The “Alias” field is used to specify an alternative name for the table. This is required if a table is included in the table list more than once. Choose between inner join, left outer join, right outer join, and full outer join using the “Join” drop-down list. If you are unsure of the purpose of the different types of join operations leave the default value unchanged.

Rearranging tables

The order and nesting of tables in the table tree determines the columns that are available for defining a join condition. Use the arrow buttons  to move a table around in the tree to create the nesting you want. If a table has no condition defined WordPage attempts to create one each time the table is moved. By looking for column names the parent and child share.

Testing your work

The “Test” button issues a command to the database to verify that the current information produces a valid statement. If it does not then the error message produced by the database is displayed to help you determine how to resolve the problem.