Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

OpenOffice 3.x Getting Started Guide
Previous Page Home Next Page

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 all at one time each day. Most of these expenses are in the Vacations table, but the fuel we buy is not. So, we will relate 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 Vacations tables also contains several fields for the type of payment used. For each field listing the payment type, there is only one entry from the Payment Type table. This is a one to one relationship: one field in one table to one entry from the other table. (It is designated 1:1.) Other tables also contain fields for the type of payment. The relationship between these fields of those tables and the Payment Type table are also 1:1.

Since the Payment Type table only provides a static list, we will not be defining a relationship between the Payment Type table and the fields of the other tables which use the entries of the Payment Type table. That will be done when the forms are created.

The Fuel and Maintenance tables do not really have a relationship even though they share similar fields: Date, and Odometer. Unless a person is in a habit of regularly getting fuel and having their vehicle serviced, the entries in these tables do not share anything in common.

Image:Tip.pngAs you create your own databases, you need to also determine where tables are related and how.
  1. We begin defining relationships by Tools > Relationships. The Automobile - OpenOffice.org Base: Relation design window opens. The icons we will use are Add Tables and New Relation.
  2. Relation design window.
  3. Click the Add Tables icon. The Add Tables window opens.
  4. Use one 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, click the name of the table and then click Add.
  5. Click Close when you have added the tables you want.
  6. Added table lists.

Defining the relationship between the Vacations and Fuel tables

Two ways exist to do this:

  • Click and drag the Date field in the Fuel table to the Date field in the Vacations table. When you release the mouse button, a connecting line forms between the two date fields.
  • Designation for a 1:n relationship.
  • Or, click the New Relation icon. This opens the Relations window. Our two tables are listed in the Tables involved section.
    1. In the Fields involved section, click the dropdown list under the Fuel label.
    2. Setting the relationship between tables.
    3. Select Date from the Fuel table list.
    4. Click in the cell to the right of this dropdown list. This opens a dropdown list for the Vacations table.
    5. Select Date from the Vacations table list. It should now look like the figure below.
    6. Click OK.
    7. Selected fields in a relationship.

Modifying the Update options and Delete options section of the Relation window

  1. Right-click the line connecting the Date fields in the two table lists to open a context menu.
  2. Select Edit to open the Relation window.
  3. Select Update cascade.
  4. Select Delete cascade.
Update options and Delete options section.

While these options are not absolutely necessary, they do help. Having these options selected permits you to update a table that has a relationship defined with another table. It also permits you to delete a field from the table.

Top of page



OpenOffice 3.x Getting Started Guide
Previous Page Home Next Page

 
 
  Published under the terms of the Creative Commons License Design by Interspire