0% found this document useful (0 votes)
14 views

LibreOffice Guide 12

The document describes various drawing and editing tools in LibreOffice Draw including transforming objects to curves, using transparency and color gradients, duplicating objects, cross-fading between objects, grouping and combining objects, arranging objects, inserting and editing pictures, working with 3D objects, exporting files, and inserting comments.

Uploaded by

Neuer Family
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

LibreOffice Guide 12

The document describes various drawing and editing tools in LibreOffice Draw including transforming objects to curves, using transparency and color gradients, duplicating objects, cross-fading between objects, grouping and combining objects, arranging objects, inserting and editing pictures, working with 3D objects, exporting files, and inserting comments.

Uploaded by

Neuer Family
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

In all three cases you are initially asked if you want to transform the object to a curve.

This is a
necessary first step, so click Yes. Then you can move the object handles to produce the desired
effect. See the Draw Guide Chapter 4 Changing Object Attributes for more information on how to
distort an object.

Dynamic transparency gradients


You can control transparency gradients in the same manner as color gradients. Both types of
gradient can be used together. With a transparency gradient, the direction and degree of object fill
color changes from opaque to transparent. In a regular gradient, the fill changes from one color to
another, but the degree of transparency remains the same.
The Transparency and Gradient tools on the Mode toolbar dynamically control transparency and
color gradients. See the Draw Guide Chapter 4 Changing Object Attributes for more information on
how to create transparencies and gradients in an object.

Duplication
Duplication makes copies of an object while applying a set of changes such as color or rotation to
the duplicates that are created.
1) Click on an object or group of objects and go to Edit > Duplicate on the Menu bar or use
the keyboard shortcut Shift+F3 to open the Duplicate dialog (Figure 206).

Figure 206: Duplicate dialog

2) Select the required options chosen from the options


available. For example, when the options in the dialog
are applied to a rectangle, they produce the result shown
in Figure 207.

Figure 207: Duplication result

Chapter 7 Getting Started with Draw | 221


Cross-fading
Cross-fading transforms one object shape to another object shape and only works when two
objects are selected.
1) Select two differently shaped objects.
2) Go to Edit > Cross-fading on the Menu bar to open the Cross-fading dialog (Figure 208).
3) Select Increments to determine the number of shapes between the two objects.
4) Select Cross-fading attributes to apply a gradual change of line and fill properties
between the two objects.
5) Select Same orientation to apply a smooth transition between the two objects.
6) Click on OK and the result is a new group of objects with the first object selected as the
start object and the second object selected as the end object. For example, when the
options in the dialog are applied to a rectangle and a triangle, the cross fade produces the
result shown in Figure 209.

Figure 208: Cross-fading dialog

Figure 209: Cross-fading result

Combining multiple objects


Using Draw, you can group or combine objects together allowing you to treat multiple objects as
one unit, or to merge objects to form a new shape. For more information, see the Draw Guide
Chapter 5 Combining Multiple Objects.
Grouping of objects is similar to putting objects into a container. You can move the objects as a
group and apply global changes to the objects within the group. A group can always be undone
and the objects that make up the group can always be manipulated separately. The objects within
a group also retain their own individual properties.
Combining objects is a permanent merging of objects that creates a new object. The original
objects are no longer available as individual entities and cannot be edited as individual objects.
Any editing of a combined object affects all the objects that were used when combination was
carried out.

222 | Getting Started with LibreOffice 5.1


Grouping
Temporary grouping
A temporary grouping is when several objects are selected using the Select icon on the Drawing
toolbar or using the mouse to drag a rectangle around the objects (also known as a marquee). Any
changes to object parameters you carry out are applied to all of the objects within the temporary
group. For example, you can rotate a temporary group of objects in its entirety.
To cancel a temporary grouping of objects simply click outside of the selection handles displayed
around the objects.
Permanent grouping
A permanent grouping of objects can be created after you have selected your objects. Go to
Modify > Group on the Menu bar, or right-click on the selection and select Group from the context
menu, or use the keyboard shortcut Ctrl+Shift+G. When you deselect your selection the objects
remain grouped together.
When objects are permanently grouped, any editing operations carried out on that group are
applied to all members of the group. If you click on one member of the group, the whole group is
selected.
You can edit an individual member of a group without ungrouping or breaking the group. Select the
group and go to Modify > Enter Group, or right-click and select Enter Group from the context
menu, or use the keyboard shortcut F3, or double-click on the group.
When you have finished editing an individual member of a group, go to Modify > Exit Group, or
right-click and select Exit Group from the context menu, or use the keyboard shortcut Shift+F3.
Ungrouping
To ungroup or break apart a group of objects, select the group then go to Modify > Ungroup on
the Menu bar, or right-click and select Ungroup from the context menu or use the keyboard
shortcut Ctrl+Alt+Shift+G.

Combining objects
Combining objects is a permanent merging of objects that creates a new object. The original
objects are no longer available as individual entities and cannot be edited as individual objects.
Any editing of a combined object affects all the objects that were used when combination was
carried out.
Select several objects, then go to Modify > Combine on the Menu bar, or right-click on the objects
and select Combine from the context menu, or use the keyboard shortcut Ctrl+Shift+K.
After you have selected your objects, the Merge, Subtract, and Intersect functions also become
available so that you can create a new object from your selected objects. See the Draw Guide
Chapter 5 Combining Multiple Objects for more information on these functions.

Arranging, aligning, and distributing objects


In Draw you can arrange, align, and distribute selected objects in relation to each other:
Arrange the position of an object by moving it either forward or backward in relation to the
order of objects.
Align objects with respect to each other using Left, Centered, or Right for horizontal
alignment and Top, Center, or Bottom for vertical alignment.
Distribute objects so that the space between each of the objects is the same.
See the Draw Guide Chapter 5 Combining Multiple Objects for more information on arranging and
aligning objects in relation to each other.

Chapter 7 Getting Started with Draw | 223


Inserting and editing pictures
Draw contains a number of functions for editing pictures or raster graphics (bitmaps); for example,
photos and scanned images. This includes the import and export of graphics, and conversion from
one graphic format to another.
Draw includes a large range of graphic filters so that it can read and display several graphic file
formats. It also includes several tools for working with raster graphics, but does not have the same
functionality as specialized graphic programs like Gimp or Adobe Photoshop. See the Draw Guide
Chapter 6 Editing Pictures for more information.
You can add pictures from several sources:
Directly from a scanner (Insert > Picture > Scan)
Images created by another program, including photographs from a digital camera (Insert >
Picture > From File)
The Draw Gallery; see Chapter 11 Graphics, the Gallery, and Fontwork in this guide for
more information.

Working with 3D objects


Although Draw does not match the functionality of the leading drawing or picture editing programs,
it is capable of producing and editing very good 3D drawings.
Draw offers two types of 3D objects: 3D bodies and 3D shapes. Depending on which type you
choose, there are different methods of editing of a 3D object (rotation, illumination, perspective,
and so on) with 3D shapes being simpler to set up and edit than 3D bodies. However, 3D bodies
currently allow for more customization.
See the Draw Guide Chapter 7 Working with 3D Objects for more information.

Exporting graphics
Draw saves graphics and images in the open source format *.odg. To save a graphic or the entire
file in another format, use File > Export and select a format from the list displayed. The graphic
formats that Draw can export and save to are listed in Appendix B Open Source, Open Standards,
OpenDocument in this guide.
You can also export Draw files to HTML, XHTML, PDF, or Flash. PDF export for modules of
LibreOffice is described in Chapter 10 Printing, Exporting, and E-mailing of this guide.
HTML export uses a conversion wizard that creates as many web pages as there are pages in
your Draw document. You can optionally choose to display pages in frames with a navigator and
set an index page. For more information, see Chapter 12 Creating Web Pages in this guide.

Inserting comments in a drawing


You can insert comments into your drawing in a similar process to the one used in Writer and Calc.
1) Go to Insert > Comment on the menu bar. A small box containing your initials appears in
the upper left-hand corner of your drawing with a larger text box beside it (Figure 210).
Draw automatically adds your name and the date at the bottom of this text box.
2) Type or paste your comment into the text box. You can apply basic formatting to parts of the
text by selecting it, right-clicking, and choosing from the context menu. From this menu, you
can also delete the current comment, all the comments from the same author, or all the
comments in the document.

224 | Getting Started with LibreOffice 5.1


3) You can move the small comment markers to anywhere you wish on the drawing. Typically
you might place it on or near an object you refer to in the comment.
4) To show or hide the comment markers, go to View > Comments on the Menu bar.

Figure 210: Inserting comments


You can go to Tools > Options > User Data to enter the name you want to appear in the Author
field of the comment.
If more than one person edits the document, each author is automatically allocated a different
background color.

Chapter 7 Getting Started with Draw | 225


Chapter 8
Getting Started with Base
Relational Databases in LibreOffice
Introduction
A data source, or database, is a collection of pieces of information that can be accessed or
managed by LibreOffice. For example, a list of names and addresses is a data source that could
be used for producing a mail merge letter. A shop stock list could be a data source managed
through LibreOffice.
This chapter covers creating a database, showing what is contained in a database and how the
different parts are used by LibreOffice.

Note
LibreOffice uses the terms Data Source and Database to refer to the same thing,
which could be a database such as MySQL or dBase or a spreadsheet or text
document holding data.

A database consists of a number of fields that contain the individual pieces of data. Each table of
the database is a group of fields. When creating a table, you also determine the characteristics of
each field within it. Forms are for data entry into the fields of one or more tables which have been
associated with the form. They can also be used for viewing fields from one or more tables
associated with the form. A query creates a new table from the existing tables based upon how you
create the query. A report organizes the information from the fields of a query into a document
according to your requirements.

Note
LibreOffice Base uses the HSQL database engine. All of the files created by this
engine, including the database forms, are kept in one zipped file.

Caution
To use Base, you need to use a Java Runtime Environment (JRE). Please go to Tools
> Options > LibreOffice > Advanced to select a JRE from those installed on your
computer.

If a JRE is not already installed, you will need to download and install one. For
Windows, you need to get Java from www.java.com. For Linux, you can download it
from the same website or you can use openjdk-7-jre, available from the repository of
your Linux version. Mac OS X users can install a JRE from Apple Inc.

Base creates relational databases. This makes it fairly easy to create a database in which the
fields of the database have relationships with each other.
For example: Consider a database for a library. It will contain a field for the names of the authors
and another field for the names of the books. There is an obvious relationship between the authors
and the books they have written. The library may contain more than one book by the same author.
This is what is known as a one-to-many relationship: one author and more than one book. Most if
not all the relationships in such a database are one-to-many relationships.
Consider an employment database for the same library. One of the fields contains the names of
the employees while others contain the social security numbers, and other personal data. The
relationship between the names and social security numbers is one-to-one: only one social security
number for each name.
If you are acquainted with mathematical sets, a relational database can easily be explained in
terms of sets: elements, subsets, unions, and intersections. The fields of a database are the

Chapter 8 Getting Started with Base | 227


elements. The tables are subsets. Relationships are defined in terms of unions and intersections of
the subsets (tables).
To explain how a database works and how to to use it, we will create one for automobile expenses.

Planning a database
The first step in creating a database is to ask yourself many questions. Write them down, and
leave some space between the questions to write the answers later. At least some of the answers
should seem obvious after you take some time to think.
You may have to go through this process a few times before everything becomes clear in your
mind and on paper. Using a text document for these questions and answers makes it easier to
move the questions around, add additional questions, or change the answers.
Here are some of the questions and answers I developed before I created a database for
automobile expenses. I had an idea of what I wanted before I started, but as I began asking
questions and listing the answers, I discovered that I needed additional tables and fields.
What are the fields going to be? My expenses divided into three broad areas: fuel purchases,
maintenance, and vacations. The annual cost for the cars license plate and drivers license every
four years did not fit into any of these. It will be a table of its own: license fees.
What fields fit the fuel purchases area? Date purchased, odometer reading, fuel cost, fuel quantity,
and payment method for it. (Fuel economy need not be included, as it can be calculated using a
query.)
What fields fit the maintenance area? Date of service, odometer reading, type of service, cost of
service, and next scheduled service of this type (for example, for oil changes, list when the next oil
change should be). But it would be nice if there was a way to write notes. So a field for notes was
added to the list.
What fields fit the vacations area? Date, odometer reading, fuel (including all the fields of the fuel
table), food (including meals and snacks), motel, total tolls, and miscellaneous. Since these
purchases are made by one of two bank cards or with cash, I want a field to state which payment
type was used for each item.
What fields fit into the food category? Breakfast, lunch, supper, and snacks seem to fit. Do I list all
the snacks individually or list the total cost for snacks for the day? I chose to divide snacks into two
fields: number of snacks and total cost of snacks. I also need a payment type for each of these:
breakfast, lunch, supper, and total cost of snacks.
What are the fields that are common to more than one area? Date appears in all of the areas as
does odometer reading and payment type.
How will I use this information about these three fields? While on vacation, I want the expenses for
each day to be listed together. The date fields suggest a relationship between the vacation table
and the dates in each of these tables: fuel and food, This means that the date fields in these tables
will be linked as we create the database.
The type of payment includes two bank cards and cash. So we will create a table with a field for
the type of payment and use it in list boxes in the forms.

Tip
While we have listed fields we will create in the tables of the database, there is one
more field that may be needed in a table: the field for the primary key, an identifier
unique to each record. In some tables, a suitable field for the primary key has already
been listed. In other tables such as the payment type, an additional field for the primary
key must be created.

228 | Getting Started with LibreOffice 5.1


Creating a new database
To create a new database, select File > New > Database from the menu bar, or click the arrow
next to the New icon on the Standard toolbar and select Database from the drop-down menu. Both
methods open the Database Wizard.
On the first page of the Database Wizard, select Create a new database and then click Next.
The second page has two questions. Make sure the choice for the first question is Yes, register
the database for me and the choice for the second question is Open the database for editing.
Click Finish.

Note
In Writer, the F4 key opens and closes the Data Source window containing the list of
registered databases. In Calc, press Ctrl+Shift+F4 to open the Data Source window. If
a database is not registered, this window will not contain it, so you cannot access the
database in Writer or Calc.

Save the new database with the name Automobile. This opens the Automobile LibreOffice Base
window. Figure 211 shows part of this window.

Figure 211: Creating database tables

Tip
Every time the Automobile database is opened, the Automobile LibreOffice Base
window opens. Changes can then be made to the database. The title for this window is
always <database name> LibreOffice Base.

Chapter 8 Getting Started with Base | 229


Caution
As you create a database, you should save your work regularly. This means more than
saving what you have just created. You must save the whole database as well.

For example, when you create your first table, you must save it before you can close it.
This makes it part of the database in memory. But it is only when you save the
database file that the table is written to disk.

Note
Database files in Open Document Format are stored with the *.odb extension. This file
format is actually a container of all elements of the database, including forms, reports,
tables, and the data itself. The same format can also store a connection to an external
database server instead of the local data, for example, to access a MySQL or
PostgresSQL database server in your network.

Creating database tables


In a database, a table stores information in a group of things we call fields. For example, a table
might hold an address book, a stock list, a phone book or a price list. A database must have at
least one table and may have several.
Each field of a table contains information of a single type. For example, the Phone field of an
address book would only contain phone numbers. Similarly, a price list table could contain two
fields: Name and Price. The Name field would contain the names of the items; the Price field
would contain the amount of each item.
To work with tables, click the Tables icon in the Database list, or press Alt+a. The three tasks that
you can perform on a table are in the Tasks list (see Figure 211).

Using the Wizard to create a table


Wizards are designed to do the basic work. Sometimes this is not sufficient for what we want; in
those cases we can use a wizard as a starting point and then build upon what it produces.
The Table Wizard in Base contains two categories of suggested tables: business and personal.
Each category contains sample tables from which to choose. Each table has a list of available
fields. We can delete some of these fields and add other fields.
A field in a table is one bit of information. For example, a price list table might have one field for
item name, one for the description, and a third for the price.
Since none of the fields we need for our Automobile database are contained in any of the sample
wizard tables, we will create a simple table using the wizard that has nothing to do with our
database. This section is merely an exercise in explaining how the Wizard works.
The Wizard permits the fields of the table to come from more than one suggested table. We will
create a table with fields from three different suggested tables in the Wizard.

Caution
Every table requires a Primary key field. (What this field does will be explained later.)
We will use this field to number our entries and want that number to automatically
increase as we add each entry.

230 | Getting Started with LibreOffice 5.1


Click Use Wizard to Create Table. This opens the Table Wizard (Figure 212).
Step 1: Select fields
We will use the CD-Collection Sample table in the Personal category and Employees in the
Business category to select the fields we need.
1) Category: Select Personal. The Sample Tables drop down list changes to a list of personal
sample tables.
2) Sample tables: Select CD-Collection. The Available fields box changes to a list of available
fields for this table.
3) Selected fields: Using the > button, move the following fields from the Available fields
window to the Selected fields window in this order: CollectionID, AlbumTitle, Artist,
DatePurchased, Format, Notes, and NumberofTracks.
4) Selected Fields from another sample table. Click Business as the Category. Select
Employees from the drop down list of sample tables. Use the > button to move the Photo
field from the Available fields window to the Selected fields window. It will be at the bottom
of the list directly below the NumberofTracks field.
5) If you make a mistake in selecting fields, click on the field name in the Selected fields list
and use the < button to move it from the Selected fields list back to the Available fields list.
6) If you make a mistake in the order of the selected fields, click on the field name that is in
the wrong order and use the Up or Down arrow on the right side of the Selected fields list
to move the field name to the correct position.
7) Click Next.

Figure 212: Selecting fields for the table

Step 2: Set field types and formats

Figure 213: Changing field types

Chapter 8 Getting Started with Base | 231


In this step you give the fields their properties. When you click a field, the information on the right
changes. (See Figure 213.) You can then make changes to meet your needs. Click each field, one
at a time, and make the changes listed below.

Note
If any of these fields requires a mandatory entry, set Entry required to Yes. A blank field
will then not be allowed. In general, only set Entry required to Yes if something must
always be put in that field. By default, Entry required is set to No.

CollectionID: Change AutoValue from No to Yes. (example of a mandatory entry)


AlbumTitle:
Entry required: Leave Entry required as No, unless all of your music is in albums.
Length: Unless you have an album title that exceeds 100 characters counting the
spaces, do not change the length.
Artist: Use the Default setting. Since music always has artists, set Entry Required to Yes.
Date Purchased: Field type: default date setting. Entry required should be No. (You may not
know the date.)

Note
In Base the maximum length of each field must be specified on creation. It is not easy
to change this later, so if in doubt specify a greater length. Base uses VARCHAR as the
field format for text fields. This format uses only the actual number of characters in a
field up to the limit set, so a field containing 20 characters will occupy only 20
characters even if the limit is set at 100. Two album titles containing 25 and 32
characters respectively will use space for 25 and 32 characters and not 100 characters.

Format: Only change the Entry Required setting: from No to Yes.


Notes: No changes are required.
NumberofTracks: Change the Field Type to Tiny Integer [TINYINT]. Your allowable number
of tracks will be 127. Small Integer [SMALLINT] would allow 32768 tracks if you needed
more than 127 tracks.
Photo: Use the default settings.
When you have finished, click Next.

Note
Each field has a Field Type, which must be specified. Types include text, integer, date,
and decimal. If the field is going to have general information in it (for example, a name
or a description), use text. If the field will always contain a number (for example, a
price), the type should be decimal or another numerical field. The wizard picks the right
field type, so to get an idea of how this works, see what the wizard has chosen for
different fields.

Step 3: Set primary key


1) Create a primary key should be checked.
2) Select option Use an existing field as a primary key.
3) In the Fieldname drop down list, select CollectionID.
4) Check Auto value if it is not already checked. Click Next.

232 | Getting Started with LibreOffice 5.1


Note
A primary key uniquely identifies an item (or record) in the table. For example, you
might know two people called Randy Herring or three people living at the same
address and the database needs to distinguish between them.

The simplest method is to assign a unique number to each one: number the first
person 1, the second 2, and so on. Each entry has one number and every number is
different, so it is easy to say record ID 172. This is the option chosen here:
CollectionID is just a number assigned automatically by Base to each record of this
table.

Step 4: Create the table


1) If desired, rename the table at this point. If you rename it, make the name meaningful to
you. For this example, make no changes.
2) Leave the option Insert data immediately checked.
3) Click Finish to complete the table wizard. Close the window created by the table wizard.
You are now back to the main window of the database with the listing of the tables, queries,
forms, and reports. Notice that a table named CD-Collection is now listed in the Tables
portion of the window.
4) Click the Save button at the top of the main window.

Creating a table by copying an existing table


If you have a large collection of music, you might want to create a table for each type of music you
have. Rather than creating each table from the wizard, you can make copies of the original table,
naming each according to the type of music contained in it.
1) Click on the Tables icon in the Database pane to see the existing tables.
2) Right-click on the CD-Collection table icon. Choose Copy from the pop-up menu.
3) Move the mouse pointer below this table, right-click, and select Paste. The Copy table
dialog opens.
4) Change the table name to CD-Jazz and click Next.
5) Click the >> button to move all the fields from the left box to the right box and click Next.
6) Since all the fields already have the proper Field type, no changes should be needed.
However, this is the time and place to make any changes if they are needed. (See Caution
below for the reason why.) Click Create. The new table is created.
7) Click the Save button at the top of the main database window.

Caution
Once tables have been created using the wizard, and data has been entered, editing a
table should be very limited. You can add or delete fields, but adding a field requires you
to enter the data for that one field for every existing record with an entry for that field.

Deleting a field deletes all the data once contained in that field. Changing the field type
of a field can lead to data being lost either partially or completely. When creating a new
table, it pays to create the fields with the correct names, length, and format before you
add any data.

Deleting a table removes all of the data contained in every field of the table. Unless you
are sure, do not delete a table.

Chapter 8 Getting Started with Base | 233


Creating tables in Design View
Design View is a more advanced method for creating a new table, in which you directly enter
information about each field in the table. We will use this method for the tables of our database.

Note
While the Field type and formatting are different in Design View, the concepts are the
same as in the Wizard.

The first table to be created is Fuel. Its fields are FuelID, Date, FuelCost, FuelQuantity, Odometer,
and PaymentType.
1) Click Create Table in Design View (which opens the Table Design dialog).
2) FuelID field: Type FuelID as the first Field Name. Press the Tab key to move to the Field
Type column. Select Integer [INTEGER] as the Field Type from the drop down list. (The
default setting is Text [VARCHAR].)

Tip
A shortcut for selecting from the Field Type drop down list: press the key for the first
letter of the choice. You can cycle through the choices for a given letter by repeatedly
pressing that key.

a) Change the Field Properties in the bottom section.


Change AutoValue from No to Yes.
b) Set FuelID as the Primary key.
Click in the Field Name cell directly below FuelID. The dialog automatically sets FuelID
as the primary key and places a key icon in front of FuelID (Figure 214).

Figure 214: Defining the primary key field

Tip
Certain of the Integer filed types (Integer and BigInt for example) have an AutoValue
Field Property. When using one of these field types, your selection of Yes for the
AutoValue value automatically makes the field the primary key.

Primary keys for any other field type must be selected by right-clicking the rectangle
before the field and selecting Primary key in the context menu.

234 | Getting Started with LibreOffice 5.1


Note
The primary key serves only one purpose: to identify each record uniquely. Any name
can be used for this field. We have used FuelID for convenience, so we know to which
table it belongs.

3) All other fields (Date, FuelCost, FuelQuantity, Odometer, and PaymentType):


a) Type the next field name in the Field Name column.
b) Select the Field Type for each field.
For Date use Date[DATE]. (Press the D key to select it.)
All other fields use Number [NUMERIC]. (Press the N key once to select it.)
PaymentType uses Text [VARCHAR], the default setting.
c) FuelCost, FuelQuantity, and Odometer need changes in the Field Properties section
(Figure 215).
FuelCost: Change the Length to 5 and Decimal places to 2. Click the Format
example ellipse button (...) (Figure 215). This opens the Field Format window
(Figure 216). Use Currency as the Category and your currency as the Format.
My currency has two decimal places. Use what is appropriate for yours.
FuelQuantity: Change Length to 6 and Decimal places to 3. (Many fuel pumps
measure fuel to thousandths of a gallon in the USA.) Odometer: Change the
Length to 10 and the Decimal places to 1.
d) Repeat steps a) through c) until you have entered all of the fields.

Figure 215: Changing field properties

e) To access additional formatting options, click the ellipse button () to the right of the
Format example field.
Description can be any of the categories listed in the figure below, or can be left blank.

Chapter 8 Getting Started with Base | 235


Figure 216: Format example options

4) To save and close the table, select File > Save. Name the table Fuel. Close the Fuel table.
5) In the main database window, click the Save button.

Figure 217: Fields in Vacations table


Follow the same steps to create the Vacations table. The fields, field types, and Descriptions are
listed in Figure 217.
Making Date the primary key has to be done in a different way because this fields field type is
Date, not Integer.
1) Right-click to the left of the field name Date.
2) Select Primary Key in the context menu.

236 | Getting Started with LibreOffice 5.1


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 219). 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 219.
e) Modify the Update options and Delete options section of the Relation window (Figure
220).
i) Select Update cascade.
ii) Select Delete cascade.

Figure 218: Designation for a 1:n relationship

Chapter 8 Getting Started with Base | 237


Figure 219: Selected fields in a relationship

Tip
The primary key can contain more than one field. (Its foreign key1 will contain the same
number of fields.) If this were the case in Figure 219, the other fields of the primary field
for the Fuel table would be listed under Date. The corresponding fields of the foreign
key would be listed under Vacations. Detailed information about this is in the Base
Guide.

Figure 220: Update options and Delete options section


f) Click OK.
g) Save the Relation Design dialog if the Save button is active.
h) Close the Relation Design dialog.
i) Click the Save button at the top of the main database window.
While these options are not strictly necessary, they do help. Having them selected permits you to
update a table that has a relationship defined with another table which has been modified. It also
permits you to delete a field from the table without causing inconsistencies.

Creating a database form


Databases are used to store data. But, how is the data put into the database? Forms are used to
do this. In the language of databases, a form is a front end for data entry and editing.
A simple form consists of the fields from a table (Figure 221). More complex forms can contain
much more, including additional text, graphics, selection boxes, and many other elements. Figure
222 is made from the same table with a text label (Fuel Purchases), a list box placed in
PaymentType, and a graphic background.
A list box is useful when a field contains a fixed choice of options. It saves you from having to type
data by hand, and ensures that invalid options are not entered.

1 A field in a table that stores values of the primary key of records in another table.

238 | Getting Started with LibreOffice 5.1


Figure 221: Fields of a simple form
Figure 222:Simple form with additions

In our database, payments for food or fuel might be made from one of two credit cards (Dan or
Kevin) or in cash, so these would be the available options for all boxes that contain payments.
To create a list box, we first need to create a small, separate table containing the options. This is
then linked to the corresponding field in the form. The topic is dealt with in detail in the Base User
Guide and will not be pursued further here.

Using the Wizard to create a form


We will use the Form Wizard to create a Vacations form, which will contain a form and a subform.
In the main database window (Figure 211), click the Forms icon in the left column. In the Tasks list,
double-click Use Wizard to Create Form to open the Form Wizard (Figure 223). Simple forms
require only some of these steps, while more complex forms may use all of them.
Step 1: Select fields
1) Under Tables or queries, select Table: Vacations. Available fields lists the fields for the
Vacations table.
2) Click the right double arrow to move all of these fields to the Fields in the form list. Click
Next.

Figure 223: Form Wizard steps

Chapter 8 Getting Started with Base | 239


Step 2: Set up a subform
Since we have already created a relationship between the Fuel and Vacations tables, we will use
that relationship. If no relationship had been defined, this would need to be done in step 4.
1) Click the box labeled Add Subform
2) Click Subform based upon existing relation.
3) Fuel is listed as a relation we want to add. So click Fuel to highlight it, as in Figure 224.
Click Next.

Figure 224: Adding a subform


Step 3: Add subform fields
This step is similar to step 1. The only difference is that not all of the fields will be used in the
subform.
1) Fuel is preselected under Tables or queries.
2) Use the >> button to move all the fields to the right.
3) Click the FuelID field to highlight it.
4) Use the < button to move the FuelID to the left (Figure 225).
5) Click Next.

Figure 225: Selecting fields of a sub form

Step 4: Get joined fields


This step is for tables or queries for which no relationship has been defined. Because we have
already defined the relationship, the wizard skips this step.

240 | Getting Started with LibreOffice 5.1

You might also like