Databases with QBE

2011 April 25

These are some very terse notes reflecting my recent decision to emphasize the visual QBE (Query By Example) instead of SQL as the database query language. You can use QBE in database products such as Microsoft Office Access and OpenOffice.org or LibreOffice.

Creating a New Database

Access: Start Microsoft Office Access. Using the "Office" button, select "New". Enter the file name and click on the "create" button.

Open/Libre Office: Start Open or Libre Office. Click on the "Database" button in the Start Center. Leave "Create a new database" selected, and click on "Next". Leave everything selected and click on "Finish." Enter the file name and click on "Save".

Creating a Table

Access

When you created the database, it has opened "Table 1" in "Datasheet" view. Rename the table, then switch to "design view". Enter the field names and data types. Be sure one field (or in some cases you may need a combination of fields) is selected as the primary key (indicated by a key icon to the left of the field name).

Switch to the "datasheet" view and enter some records for the table.

To create additional tables, select the "Create" tab and click on "Table", then select the "design" view.

Open/Libre

Under "database" (left hand side), click on "tables" if it is not already selected. Under "tasks" click on "create table in design view". Enter the field names and data types. Be sure one field (or in some cases you may need a combination of fields) is selected as the primary key (indicated by a key icon to the left of the field name). For the primary key field, right click on the area to the left of the field name and select "primary key". Click on the "save" icon. Enter the table name and then click on "OK".

To enter records for the table, go back to the Start Center (main window). (You may need to move or close the "create table" window so that you can get back to the Start Center.) Double click on the table's name, or right click and "open" the table.

Queries

Access: To create a query, click on the "Create" tab and then "Query Design." Select the table(s) you want the query to draw data from; then click on "close".

Select the field(s) you want the query to display. You may also select fields for sorting and criteria for displaying rows (criteria can be expressed as "< 10", etc.). Save and name the query.

To run the query and display its results, click on the red "!" Note: if the "!" does not seem to be available, right click on the query tab or on the view selector and change the view to "datasheet".

Open/Libre

In the Start Center, under "Database" click on "Queries". Under "Tasks", click on "Create query in design view".

Select fields and optionally sorting and criteria the same as for Access. Save and name the query.

To run the query, click on the "run query" icon or press F5.

Modifying a Table

[TO BE WRITTEN]

Creating a Form

[TO BE WRITTEN]

Creating a Query with Two Tables Using Natural Join

[TO BE WRITTEN]

Creating a Report

[TO BE WRITTEN]