Use the Master/Detail browser to view or edit data from multiple tables, snapshots, views or queries linked by foreign keys or a user-defined master-detail relationship. This is typical of a database setup from an Entity/Relationship diagram, where one table's objects are related to another table's objects by a linking field or fields.
For example, you could start with the DEPARTMENT table, and display details. Select a department record in the Master grid, and the detail grid will display employee records for that department only. If multiple tables are linked by foreign keys, you can add additional details beneath the first.
To access the Master/Detail Browser
» From the Database menu, selectReport | Master/Detail Browser. Navigator
To the left of the Master Detail Browser is the Master Detail Navigator. As you add detail tables, they are added to the navigator under the original table. Using the navigator can make it much easier to control very detailed sets of master/details.
Within the navigator, you can hide or display the schema name and delete detail nodes. You can use the navigator to find the grid for a specific detail table.
To find a detail
» In the Navigator, click on the node for the detail you want to view.
pane. Single Grid Mode
You can set Toad to display only one grid at a time by checking the Single Grid Mode box on the Master/Detail toolbar. Use the navigator to select which grid you want to see.
You can generate XML output from a master-detail relationship. From the master-detail grids, you can send a query to the Editor that will generate the output. Output will be created in XML Form, one XML document per row.
This feature is available only in Oracle 9iR2 and newer, and when the Master-Detail relationship consists of one master and one detail.
To generate XML output
1. From the Master Detail browser, open or create a relationship that consists of one Master and one detail.
2. Right-click on the master grid, and selectSend XMLGEN Query to Editor. 3. Switch to theEditorwindow in Toad.
4. Execute the query to generate XML output.
Toad creates an XML document for each row in the master dataset, with each XML document containing all corresponding detail rows.
To save XML output to disk
1. Right-click on theEditor gridand chooseExport BLOBs (longs, raws). 2. Select theXMLDATA columnfrom theExport this Columndrop down.
3. Enter or select adirectorywhere you want the files stored in theExport Pathbox. 4. Select the method of naming your files:
l Use sequentially numbered files
l Export to files named for the value in this column (select the column)
5. ClickOK.
Before you can add details, you first need to select the master object for the relationship view. To select a master object
1. From the Database | Report menu, selectMaster Detail Browser. 2. In the Type box, select the type of object you want to use. 3. In the owner box, select the schema that contains the object. 4. In the Name box, select the name of the object.
The grid populates with the contents of your selected object. You can easily add detail datasets to a master grid, or to a detail grid.
If you choose Other as the dataset type, (not Table(FK)), then the drop down will include Reverse Foreign Keys. This lets you define the master-detail relationship by going through a foreign key in reverse.
To add a dataset
1. From the Master/Detail Browser, open a master object. 2. On the master toolbar, click .
3. Behavior is determined by number of foreign keys:
One foreign-key defined detail Added automatically. Multiple foreign-key defined
details
Choose from a list of available tables and click OK.
No constraints defined Define a relationship in the Define Master-Detail Relationship dialog.
If there is no foreign key specified, you can create a Master/Detail relationship by hand. To define a master/detail relationship
1. From the Master/Detail browser, select a master object. 2. Click .
l If there is no defined detail dataset, the Master/Detail Define Relationship dialog
displays. Continue withstep 3.
l If there is only one defined detail dataset, it is displayed. In the Type drop-down,
selectOther, and then click .
3. In the Master area, select the columns you want to link and click the>arrow to move them to the Key Columns list.
4. Select any columns you do not want to link from the Key Columns grid and click the< arrow to remove them.
5. In the detail area, select the Object type containing the dataset you want to link. 6. Select the schema containing the dataset.
7. Select the Object Name containing the dataset.
8. In the Available Columns grid, select the column you want to link to the selected column in the Master Table.
Note:These must be in the same order as the Key columns in the Master area. 9. ClickOK.
To close without making changes » ClickCancel.
To delete the master-detail relationship » ClickClear and Close.