Operation Manual

Defining relationships
Now that the tables have been created, what are the relationships between our tables? This is the
time to define them based upon the questions we asked and answered in the beginning.
When on vacation, we want to enter all of our expenses at once each day. Most of these expenses
are in the Vacations table, but the fuel we buy is not. So we will link these two tables using the
Date fields. Since the Fuel table may have more than one entry per date, this relationship between
the Vacations and Fuel tables is one to many (it is designated 1:n.)
The Fuel and Maintenance tables do not really have a relationship even though they share similar
fields: Date and Odometer readings.
Tip
As you create your own databases, you will also need to determine if tables are related
and how.
1) To begin defining relationships, select Tools > Relationships. The Automobile –
LibreOffice Base: Relation Design window opens and the Add Tables dialog pops up. (You
can also open it by clicking the Add Tables icon on the Relation Design window.)
2) In the Add Tables dialog, use either of these ways to add a table to the Relation Design
window:
Double-click the name of the table. In our case, do this for both Vacations and Fuel.
Or, for each table, click the name of the table and then click Add.
3) Click Close to close the Add Tables dialog when you have added the tables you want.
4) Define the relationship between the Vacations and Fuel tables: click the New Relation
icon. This opens the Relations window (Figure 213). Our two tables are listed in the Tables
involved section.
a) In the Fields involved section, click the drop-down list under the Fuel label.
b) Select Date from the Fuel table list.
c) Click in the cell to the right of this drop-down list. This opens a drop down list for the
Vacations table.
d) Select Date from the Vacations table list. It should now look like Figure 213.
e) Modify the Update options and Delete options section of the Relation window. (Figure
214)
i) Select Update cascade.
ii) Select Delete cascade.
Figure 212: Designation for a 1:n relationship
230 | Getting Started with LibreOffice 5.0