Chapter 4. RHDB Administrator Reference

This section describes how to administer your clusters using RHDB Administrator. The examples given use the following schema, which is a database named web_store containing four tables:

Figure 4-1. The Schema Used in the Reference Section

To learn more about any of these commands, refer to the Red Hat Database SQL Guide and Reference.

NoteA Note on System Objects
 

System objects are objects that the system adds to the aggregates, columns, data types, functions, languages, operators, and tables of a database; they cannot be modified or dropped, and they do not have context menus. In the Tree View, they are identified by the presence of an additional white S superimposed on a red square in the usual object icon. They are visible in the Tree View and in Summary Views only when the display of system objects is turned on.

All screenshots used in this section have the display of system objects turned off. This is not necessary to carry out the examples, it is only to make the examples simpler. You can toggle the display of system objects by selecting View -> Show System Objects from the Menu Bar.

Aggregates

In the object hierarchy under any database, you will find Aggregates. You can add an aggregate by selecting CREATE AGGREGATE from the Aggregate context menu. Once an aggregate has been created, it can also be commented on or dropped. This section describes how to create, manage, and drop an aggregate with RHDB Administrator.

In this example, you will create an aggregate called total_cost.

  1. Before creating an aggregate you must create the state transition function to be used in defining the aggregate. Expand the database under which you wish to create the function (click the + beside the database name).

  2. Right-click on Functions and select CREATE FUNCTION. The CREATE FUNCTION dialog appears.

    The function you will create will be called "cost". It will take as input the cost and quantity of an item (both specified as numeric) and return the cost of that quantity of the item.

  3. In the CREATE FUNCTION dialog, for the name for the new function type: cost

  4. In the Arguments List, type:

    numeric(7,2), numeric(7,2)
  5. From the Language drop-down list, select sql.

  6. As the Return Type, type numeric(7,2), and as an Attribute check Strict.

  7. For the Function Definition, type:
    SELECT $1 * $2 AS RESULT;

  8. Click OK to define this function.

  9. An aggregate is an object under a database, so to create a user-defined aggregate, first expand the database under which you wish to create the aggregate (click the + beside the database name).

  10. Right-click on Aggregates and select CREATE AGGREGATE. The CREATE AGGREGATE dialog appears.

  11. The first field is the name for the aggregate. Type the name: total_cost

    This aggregate will be used to determine the total cost of all items in inventory.

  12. For the Base Type, select numeric; for the State Transition Function, select cost(numeric,numeric); and for the State Type select numeric.

  13. Click OK to define this aggregate.

Note that the aggregate total_cost(numeric) has been added under the Aggregates node in the Tree View.

Also, when you click on Aggregates, an Aggregate Summary View appears to the right of the object hierarchy, showing the aggregates created in this database.

Click on the aggregate name in the Tree View to bring up a detailed view of the aggregate. (This can also be done by clicking on the aggregate name in the Summary View.)

RHDB Administrator also enables you to perform the following operations on existing aggregates:

To learn more about aggregates, refer to the Red Hat Database SQL Guide and Reference.