Creating and Saving a Query

The Queries tab allows you to query your project and locate all instances
that match criteria you specify. To create a query, you must select one or more
classes, and one or more slots within that class. You can also save queries in
the Query Library for future recall.
In this section, you will:
- Create a query.
- Run the query and view the results.
- Save the query.
- Retrieve the query and rerun it.
Creating a Query
Suppose you are interested in locating all Employees who who have a salary
greater than $40,000 dollars a year. To create the query:
- Click on the Queries tab.

- First, click the Select Class
button above the Class entry bar.
- Select Employee from the Select Classes dialog box, then click OK.

Employee is now displayed in the Class entry bar.
- With Employee showing in the Class entry bar, click the Select Slot
button above the Slot entry bar.
- Select Salary from the Select Slot dialog box and click OK.

- The menu to the right of the Slot entry bar is now active, and the entry
bar at the far right of the window reminds you that the slot you have
selected is a float. Select "is greater than" from the
menu. Next, enter 40000 in the Float entry bar.

Running the Query
Now you have set up your query, you can run it and view the results.
- To run the query, first click the Find button near the bottom right of the
window.
- To view the query results, you must click the left arrow at the far
right of the window.

- The results are shown in a Search Results window.

You can double-click on any instance to view details.
- When you are finished viewing the search results, click on the right arrow
to return to the Query window.

Saving the Query
You can save any query before or after you run it. To save the query in the
Query Library:
- Click the Add to Query Library button at the lower right of the
screen.
- Type employee_salary in the Input Query Name dialog box.

- Click OK.
Retrieving the Query
To retrieve a saved query, you can select it from the Query Library. To do
this:
- First, click the Clear button to empty the screen, so that you can see the
query operation.
- Click the Up button at the very lower right of the Query Tab.

- The Query Library is displayed.

- Click the Retrieve Query button to retrieve the query.
- Click the Down button to return to the main Query window.

The saved query is displayed in the window. If you wish, you can now alter
it or combine it with another saved query.
- Click the Find button.
- Click the left arrow at the far right of the window to view the results as
before.

- When you have finished viewing the results, you can click on the right
arrow to return to the main query window.

Getting Started With Protégé