BG4201 IntroducingBase
BG4201 IntroducingBase
Chapter 1
Introducing Base
Creating an embedded flat database
Copyright
This document is Copyright © 2014 by the LibreOffice Documentation Team. Contributors are listed
below. You may distribute or modify it under the terms of either the GNU General Public License
(http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons Attribution
License (http://creativecommons.org/licenses/by/3.0/), version 3.0 or later.
All trademarks within this guide belong to their legitimate owners.
Contributors
Dan Lewis
Reizinger Zoltán
Hazel Russman
John Viestenz
Jean Hollis Weber
Feedback
Please direct any comments or suggestions about this document to:
[email protected].
Introducing Base 3
Step 1: Field selection........................................................................................................... 32
Step 2: Sorting order............................................................................................................. 33
Step 3: Search conditions.....................................................................................................33
Step 4: Detailed or Summary................................................................................................34
Steps 5 and 6: Group by and Grouping conditions................................................................34
Step 7: Aliases...................................................................................................................... 34
Step 8: Overview................................................................................................................... 34
Detailed query example............................................................................................................. 36
Summary query example........................................................................................................... 37
Reports: use wizard to create reports.............................................................................39
Mixing Base with the rest of LibreOffice.........................................................................44
Writer......................................................................................................................................... 44
Calc........................................................................................................................................... 44
Impress...................................................................................................................................... 45
Using Base with other data sources................................................................................45
Introducing Base 4
Introduction
Base is the database component of LibreOffice. A data source, or database, is a collection of
information organized so that it can easily be accessed, managed, and updated. 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.
If you have information that you would like to organize, Base will help you do this. You could use a
spreadsheet to organize information, but maintaining a spreadsheet with Calc can often be more
complex and time consuming than using a database with Base.
This chapter is for the person who has not used Base before or who wants to review the basics of
creating and using a database. Terminology is kept to a minimum. This chapter covers the wizards
needed to create the database parts and the principles that the wizards use. It also provides
references to more information in the Base Handbook or the Base Guide (being written).
The Base Handbook and the Base Guide are for people who understand some of the basics of
how Base works and want a more in-depth discussion.
To use Base, you need to use a Java Runtime Environment (JRE). Please go to
Tools > Options > LibreOffice > Advanced to choose a JRE from those installed
on your computer.
Note If no JRE is 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.
One of the things that sometimes confuses people is terminology. Specifically, what is the
difference between a database and a data source? Base uses the terms interchangeably, as
synonyms. This is because a database is a collection of data that can come in different forms.
These include text files, spreadsheets, or a file created by a database program.
A collection of data does not serve a good purpose unless we can use the information it contains.
Therefore, a structure has to be built using data. In a spreadsheet, formulas and cell links are used
to obtain information from the data contained in it. Database programs can do the same thing.
With Base, you create a Database document file. This file contains the data and all of the
structures you create to obtain information from the data. Because everything is included in one
file, it is known as an embedded database.
Base can also be used to connect to other databases. In this case, Base creates a file to make the
connection. These are not embedded databases since they exist outside the Base file. They are
front end database documents. See the Base Handbook and Base Guide for more information.
Types of database
The two types of database are known as flat and relational. Base can create and work with both
types. This chapter discusses flat databases. Relational databases are covered in detail in the
Base Handbook and the Base Guide.
A flat database contains one or more tables, each containing one or more fields. Each table is
completely independent of all the other tables in the database. For example, you might have an
address database with several tables in it. One might contain your family’s contacts, another your
business contacts, and another your spouse’s family contacts. While some contacts are contained
in more than one table, different tables may not have the same information about the same person.
Types of database 5
A relational database contains one or more tables with one or more relationships defined between
those tables; each relationship is defined by a pair of fields. One field of each pair belongs to one
table and the second field belongs to the same or a different table. Where relationships exist
between fields in the same or different tables, a flat database could still be used, but it provides no
mechanism for defining the relationship. Instead the same data must be entered in both fields,
making data entry errors more likely. A well designed relational database requires the data to be
entered only once, reducing possible errors.
Flat database
Consider an address book. Usually, the data in an address book can be divided into groups based
upon the relationships between the data. For example, all the first names are put into one group.
Other groups can include last names, spouse names, addresses, phone numbers, birthdays, and
so on. You probably need to identify phone numbers based on their use (home, work, mobile). If
you were keeping this information in a spreadsheet, you would use one column for each one of
these groups. In a database, this column is called a field.
Other relationships that exist between data can be used to further define the structure of that data.
In an address book, one value in each of these groups describes a specific individual. In a
spreadsheet, the columns would be as above. We would rearrange the rows so that each contains
information about an individual.
This divides the data into a table. Each column contains data with the same properties. Each row
contains data that describes a specific entity or individual. Each row is called a record. The
structure of rows and columns is called a table.
The collection of data we mentioned was a flat database without any structure. Now with the table,
we have a flat database we can use to obtain information from the data.
We use queries to obtain the information. You can think of queries as way to ask questions in Base
and receive the answers. If we want to give the information to someone else, we will give them a
report that is based upon a query we created. (A report can be created from a table as well.)
So, a flat database consists of a table whose columns are called fields and whose rows are called
records. We use the table structure to ask questions and to receive answers using queries. When
providing others with information obtained from a query, we create a report. These, then, are the
things we use in a database: table with its fields and records, queries, and reports.
Caution Before creating a database, you should take some time planning what you want it to
do and why. The better your plan, the better the results you will get from using the
database.
You need to have an idea of what you want to do with the data that you have. This includes how
you will divide the data into columns, the fields, and into rows, the records. This determines what
the table will be. What information do you want to get from the data? This determines what the
queries will be. What information do you want to have in a report? So, take some time to think
through what you want first before ever creating a database.
The Base Guide has an extensive discussion on this topic in Chapter 2, Planning and Designing
your Database.
The Table Wizard (see discussion beginning on page 11) contains a list of suggested tables: some
for business purposes, and some for personal purposes. The wizard also contains a list of fields for
each of the suggested tables. Each of the fields also has been given the properties it needs.
When you create a new database, you should register it. Registration lists the
Note location of the database location in one of the configuration files of LibreOffice. You
can then access the database from Writer or Calc.
If you want to create a table with the wizard immediately after creating a new
database, select Create tables using the table wizard in addition to Open the
database for editing. If you do this, the main database window opens with the
Note Table Wizard opening in front of it.
We will discuss the main database window before the Table Wizard, so in our
example the second choice is not checked.
3) Click the Finish button at the bottom of the wizard. A standard Save as window opens.
Name and save the database.
You have created and saved a new database file that has opened the main database window. If
you wish, you can close it now and reopen it later.
These databases and how to connect to them using Base are discussed in Chapters
Tip 2 and 8 of the Base Guide.
Tasks section
This section contains a list of tasks that can be done related to the icon selected in the Database
section. When the Tables icon is selected in the Database section, three tasks appear in this
section. Two of them help you create a table, and one helps you create a view. When the Queries
icon is selected, three tasks appear to help you create a query. When the Forms icon is selected,
two tasks appear to help you create a form. When the Reports icon is selected, two tasks appear
to help you create a report.
The right side of the Tasks section has the heading Description. This area gives you information
about each of the tasks. Click any one of the tasks to see its description.
In this chapter, we are using only the wizards to create the tables, queries, forms,
Note and reports. The Base Guide discusses the rest of the tasks, their principles, and an
example of their uses.
List section
This section contains a list of the objects whose icon is selected in the Database section. Click the
Tables, Queries, Forms, or Report icon, and this section contains a list of the tables, queries,
forms, or reports respectively. The title for this section is the name of the icon selected.
A variety of things can be done with any member of the visible list by right-clicking the item and
selecting an action that appears in the context menu. The standard actions are Copy, Delete,
Rename, Edit, and Open. The context menu includes additional choices that depend upon the type
of list.
To the right of the list is a small window labeled Document view, giving you more information about
the specific document (table, query, form, or report) you have selected. The view is controlled by a
drop-down list containing three options: None, Document Information, and Document.
When Tables or Queries is selected in the Database section, only two choices are available: None
or Document. When Forms or Reports are selected, all three choices are available. Selecting
None leaves the Document view window blank.
Select Document information for a form to see who last modified the form and when it was
modified. If it has not been modified, there is no information.
Select Document and a member of the list, and you will see a snapshot of what you selected. In
most cases, you see only the top left portion because of size limitations. For a table or query, you
will see only the first few columns and rows along with any data. For a form, you will see the top
left portion of it. (If the form is small, you will see all of it.)
Document view does not work for reports. You will see all three choices in the drop-
Tip down list, but you will not see anything when you make a selection.
Database objects
Database objects are the tables, queries, forms, and reports of the database. When a new
database is created, they have to also be created to make the database's data useful.
This chapter discusses the use of wizards for creating these objects. The principles used by the
wizards are included. The example database will be a household inventory.
Page 2, Set types and formats, refers to setting the types and formats for the fields.
Note On this page, you can choose among the supplied fields, create new fields and set
their type and format, and rename fields.
Table
A table consists of one or more vertical columns and one or more horizontal rows containing
the data of the database. The data of a given table of a database share one or more common
characteristic.
Field
A field is an attribute or characteristic that divides the data of a table into columns, one column
for each attribute.
Record
A record is a row of a table. The word Tuple is sometimes used in place of record in database
literature, but record is used more often. The contents of each row share a common
characteristic.
1 2 3 4
1 Category labeled option buttons 3 Move selected fields from left to right
2 Move selected fields from right to left 4 Change the order of the listed fields
Figure 4: Step 1 of Table Wizard: Select fields
Here are the smaller steps required on this page. These will be applied to selecting
HouseholdInventory as the table and the fields in it in the example following these steps.
1) Select the category: Business or Personal. This determines what is listed in the Sample
tables drop-down list. (Select Personal for the example.)
2) Open the Sample tables drop-down list by clicking the down arrow.
3) Select the table you want to use.
(Select HouseholdInventory for the example. Available fields contains a list of this table's
fields.)
4) Move the fields you want to use in your database to the Selected fields list.
Field information
All the fields have at least four items as field information. The actual number of items depends
upon the field type. When the field type is Integer, there are five items.
Most of the field types used in Base are similar to those used in database programs. However,
different programs are likely to have some field types that are not available in Base. For example,
MEDIUMINT, is used in MySQL. Its Length is less than INTEGER and larger than SMALLINT
which Base uses.
The Field name permits you to change the spelling of the field's name. The Field type determines
the main characteristic of the field such as text, numbers, dates, times, timestamps, Boolean (for
example, yes/no, true/false, or male/female), and very large fields including images.
Use Entry required for any field that must always have a value by selecting Yes. Always be sure
that an entry will always be required before selecting Yes.
If you have a field that requires an entry, you will get an error message if you do
Caution not enter a value. You will be able add values to all the other fields once only
before the error message, But you can not add any more values until you enter
one in the field that requires one.
The Length property determines the size of the entry that can be used for a field. Each of the field
types have specific maximum lengths. So, check what these are when entering a length, and enter
what you need. You might need to change the field type if you need a larger length than your
chosen field type will permit. Then again, a field type that has a smaller length might be more
appropriate.
Text field types include CHAR, VARCHAR, VARCHAR_IGNORECASE, and MEMO. CHAR stores
entries in a fixed length. For example, the selected length is 10 and the values entered were cat,
mouse, leather, and something. These would be stored as cat0000000, mouse00000, leather000,
and something0. The zeros are added to make the length of each one 10. When this field is later
read, the zeros are ignored.
VARCHAR is variable character. Only the actual characters entered are stored up to the length
selected. If it also has a selected length of 10, the above examples are stored as cat, mouse,
leather, and something. So less storage is needed when using VARCHAR instead of CHAR. This is
especially useful when a field's values vary considerable in length. So the suggested length of 50
can be used for VARCHAR as long as the longest entry is less than or equal to 50. With 50 as the
selected length for VARCHAR with the examples above, the stored values are still cat, mouse,
leather, and something.
Use these steps to set the fields and their properties for your table:
1) To verify or modify the Field information for the selected fields,
a) Click the field name in the Selected field list.
b) Compare the field information to what you want the field to have.
c) Change any of it if necessary.
d) Repeat steps 1a-c for the rest of the fields.
2) To create a new field:
a) Click the plus (+) button. (See Figure 5.)
b) Change Field name to the field name you want.
c) Modify any of the other Field information to what you need.
d) Repeat steps 2a-c for additional fields to be created.
3) To delete an unneeded field:
a) Click the field you want to delete.
b) Click the minus (-) button.
c) Repeat steps 3a-b to delete any additional fields.
When using the table wizard to create a table, very seldom will you need to make
any changes in the field information since the suggested values are usually the ones
Note you need. However, check the Decimal places value for currency fields as the
wizard suggests using 0.
When a table is created without a primary key and should have one, you will not be
Caution able to enter any data into the table. This can be frustrating. You will first have to
learn how to use the Table Design dialog before you can correct this error. (See
Chapter 3 of the Base Guide.) So when using the table wizard always have this
checked on Page 3: Create a primary key.
There are three choices on this page of the table wizard once you have made sure that Create
primary key has been selected. This should be the default setting, but make sure anyway. The
choices are Automatically add a primary key, Use an existing field as a primary key, and Define
primary key as a combination of several fields.
The first option adds an additional field, ID as the table's primary key. Its field type is Integer.
However, Auto value is set to No. This means you would have to manually enter each value for the
field, ID. Using the second option instead of this one will permit you to have Base create the values
for the primary key for you.
The second option selection has been selected in the figure below. The field name has been
selected from the drop-down list of field names. Check the Auto value checkbox to have Base
select the values for this field automatically.
Practice exercise
Select InventoryID to be the primary key for the table and give it the Auto value property.
• Click Next to go to page 4.
A common naming practice has been to make two or more words into one word for
the name of a field or database. (Each word is capitalized when joining them.)
HouseholdInventory and InventoryID are two examples. You may use spaces in
Tip names used in a database if you want. Such names may require double quotes
when using SQL to create, delete, or modify a table or field. (See Chapter 3 of the
Base Guide for detailed information.)
Use this page to name the table you are creating. You can use the name suggested, modify it, or
give it a name of your choice. Then you have three options regarding what to do next: Insert data
immediately, Modify the table design, or Create a form based on this table. After making any
modification in the table name and selecting your option, close the table wizard.
Practice exercise
Modify the name of the table to Household Inventory. Then select the first option, Insert data
immediately. Click Finish to close the Table Wizard. The Table Data View dialog (Figure 8) opens.
This section contains basic instructions for adding and removing data in a table.
Note Chapters 3 and 4 of the Base Guide discuss this in more detail.
To insert or remove data using this dialog, it has to be opened. This can be done while creating the
table by selecting Insert data immediately in the last step of creation. Also, you can always open
any table at any time from the Main Database window to edit its data.
1) Click the Tables icon in the Database section.
2) Right-click the name of the table in the list of tables.
3) Select Open from the context menu. The table data view dialog opens.
When the dialog is opened, a cursor appears in the first cell of the row. It is ready for you to enter
data into that cell. Once you have entered data into a cell, you can move the cursor into the other
cells so that data can be entered there as well.
Entering data into the dialog is similar to entering data into the cells of a spreadsheet. The cursor
can be moved from one cell to another using the arrow keys. (In a spreadsheet, sometimes the
Enter key must be used.) Typing data only places it into the cell where the cursor is located.
There are important differences as well. Typing data into a cell of a table does not enter the data
into the table as it does in a spreadsheet. The data only appears in the cell. To enter it into the cell,
the cursor must be moved by either the Enter or by an arrow key. Finally, using the Enter key when
the cursor is in the last column of a row moves the cursor to the first column of the next row.
Entering data into an empty table: (The cursor is located in the first column of the first row.)
1) The first row:
a) Type the data into the first cell.
b) Move the cursor to the next cell. (Use the Enter or right arrow key.)
c) Repeat steps a) and b) until the cursor is in the last cell of the row.
d) Type the data into the last cell.
e) Move the cursor to the first cell of the second row. (Use the Enter key.)
2) Additional rows:
Repeat steps a) – e) in 1).
3) Close the table data view dialog, saving it if necessary.
Entering data into any empty cell of a table is very similar to the above steps.
1) Use the mouse to move the cursor to the empty cell.
2) Type the data into it.
Practical exercise
Enter this data into the Household Inventory table:
Table 2: Sample data (first 6 fields)
1 2 3 4 5 6
1 Move selected field to the right 4 Move selected field to the left
2 Move all fields to the right 5 Move selected field higher in list
3 Move all fields to the left 6 Move selected field lower in list
Notice that the drop-down list we used to select the Household Inventory table is
Tip labeled, Tables or queries. This is because a form can be created from a query just as
it can be from a table.
Control
A Control consists of a label and field. The label contains the name of the control, and the Field
contains the data entered into the form.
You have four choices in arranging your controls as shown in the figure from left to right: Columnar
– Label left, Columnar – Label on top, As Data Sheet, and In Blocks – Labels Above. Each choice
gives a slightly different layout.
Both of the columnar layouts create the controls in columns beginning with the first control at the
upper left and continuing down the left side. If additional columns are needed, they are filled in
from top to bottom and then columns from left to right. The first control is the top control in the left
column. The last control is the bottom control in the column on the right.
The Data Sheet arrangement looks like a spreadsheet with the labels across the top. This is
probably best used for a subform rather than for the main form. It is your choice.
The In Blocks – Labels Above arrangement places the controls in rows from left to right. When one
row is filled, the next control is placed at the left end of the row below. So, the first control is at the
left end of the top row, and the last control is at the right end of the bottom row.
We will use Columnar – Labels Left for the Household Inventory form.
The In Blocks – Labels Above arrangement places the controls in rows from left to right. When one
row if filled, the next control is placed at the left end of the next row below the row that is filled. So,
the first control is at the left end of the top row, and the last control is at the right end of the bottom
row.
We will use Columnar – Labels Left for the Household Inventory form.
1) Label placement: Select how you want the labels to be aligned: left or right.
Accept the Default value of Align left, or click the bottom option button to select Align right.
I strongly advise that you look at the data entry choices available, thinking about how
Tip each of these choices might meet your future needs. For instructions on the purpose
of each of these choices, see Chapter 3 of the Base Guide.
“Read only” is confusing to many people. In Edit mode, you can modify anything that
you earlier created: controls, background, and text you may have added to the page.
In this mode, you can not add nor remove any data previously entered into any of
Tip the fields unless you click the Design Mode On/Off icon to turn the design mode off.
In Read Only mode, none of the controls nor styles of the form can be changed.
However, you can add, delete, or modify data in any of the fields.
• Record number: The form numbers the rows of the underlying table from the top row to the
bottom row. The record number shown is the number of the row that appears on the form.
• Total records: This shows the total number of records of the underlying table when the
number of rows is small. With larger tables, this shows only part of the total number.
• First record: Click this arrow to go to the first record. (The record number becomes 1 or
whatever is the smallest number. If the present record is the first record, this arrow is
grayed out and not useable.)
• Previous record: Click this arrow to go to the previous record. (The record number
becomes one less than what it had been. If the present record is the first record, this arrow
is grayed out and can not be used.)
• Next record: Click this arrow to go to the next record. (The record number will be one larger
than what it has been. If the present record is the last one, no data will appear in this record
with one exception: the form contains the table's primary key, and its field property,
AutoValue, is set to Yes. Only then will the primary key show AutoValue.)
• Last record: Click this arrow to go to the last record. (The record number becomes the
largest one. If the present record is the last record, this arrow is grayed out and can not be
used.)
• New record: Click this icon if you want to create a new record becoming the last record.
(The record number becomes one larger than the previous largest one. No data appears in
the controls of this record except for a primary key control whose field property for
AutoValue is Yes.)
• Save record: Click this icon to save data that has been typed into one or more controls. The
data entered is saved to the table.
• Undo data entry: If you have made some entries but have not saved them, you can click
this icon to remove all the entries you have made in the present record since the last time
the record was saved.
• Delete record: Click this icon if you want to delete the data from all of the controls in the
present record. This will remove data that you just entered as well as the data that had
been saved earlier. (A window appears requiring you to verify that you want to delete the
data from all the controls of the present record.)
Caution Be very careful when clicking the Delete record icon. This is equivalent to deleting a
row from a table. Only do this if you are absolutely sure that you will no longer need
the data that you are deleting. The present record no longer exist in the form, and
the corresponding row of the underlying table also ceases to exist.
When records are saved, they are written to the underlying table. However, this is
Caution
done in the computer's memory (RAM). Only when the database is closed is the
data written to the Base file (.odb). As long as you are not entering a large quantity
of data to your database between closing it, you should not have a problem.
Practice exercise
1) Create five more records in the form using the data in Tables 1 and 2 below.
2) Modify the following records with the data given:
a) Change the appraised value for the piano from 6000 to 5700.
b) Delete the Description for the WiFi. (802.11g is not needed.)
Query
A query is a search of the database to locate specific types of information.
Some of this information may be what has been entered. We may want to know the appraised
value of the items in the Living Room. This produces a query whose output is a detailed list. A
query can also manipulate the data to obtain desirable information. For example: Based upon
the appraised values of the individual items, what is the total appraised value of the entire
inventory? This produces a single cell containing the total appraised value of the inventory.
Detailed query
A query that produces a detailed list as its output. The data in this list are part of the data
contained in the database. The list consists of one or more rows.
Summary query
A query that manipulates database data to produce its output. Unless the summary query is
group, its output will contain only one row and each column will contain manipulated data.
Three tools are available to help you to work with your data to get the information
you need. One is the View located in the Table section of the database. This tool
Tip allows you to view selected data. Another is the Query, which allows you to both
view and manipulate selected data. Finally, you can use the Report to create a text
document that uses a table, view, or query from the database for its information.
Steps 5 and 6 are for summary queries that groups the information you seek. While
Note an example of one of these is given, the detailed discussion of them is in Chapter 5
of the Base Guide.
1 2 3 4 56
1 Move selected field to the right 4 Move all fields to the left
2 Move all fields to the right 5 Move selected field up
3 Move selected field to the left 6 Move selected field down
Select the field to be used for sorting the information you want.
1) Open the Sort by drop-down menu by clicking the box labeled Undefined.
2) Click the field's name in this drop-down list to select it.
3) Select Ascending or Descending as the order of the sorting.
4) Click Next.
Step 7: Aliases
Alias
A name given to a field, table, or expression that can be used instead of a name it already has.
In everyday life, people are given nicknames. Sometimes they are a shorter version of the given
name, and sometimes they are quite different.
An alias is similar to a nickname. For example, the name of suggested fields in the table wizard are
often two or more words that have been combined into one word. At this point you may wish to
create aliases that have these names divided into their original words or changed to something
more meaningful.
Summary queries are a good place to use aliases. For example, we want the total appraised value
of our furnishings. The name for this, without any changes, is SUM(“AppraisedValue”). We could
use the alias: Total Appraised Value. More complex summary queries can have names that are
rather involved, and an alias is recommended.
• Click Next.
Step 8: Overview
Figure 17 shows the overview of a query. It contains three parts: naming the query, what will be
done next after the query is created, and an overview of the selections made using the wizard.
You should enter what you want to call the query in the Name of the query text box. The
suggested name combines Query with the name of the table used in the query using an underline.
Do not use the name of the table as the name of the query as well; doing so will cause an error
message. Because tables and queries can be used when creating queries, forms, and reports, a
name for a table or query can be used only one time to prevent selecting the wrong one if duplicate
names are allowed.
You have two choices after closing the query wizard: display the query results, or modify the query.
The first choice runs the query to give you an output. The second choice opens the Query Design
dialog. Because the second choice leads to something that is beyond the discussion of this
chapter, do not change the default setting (Display Query).
Like the naming of the query, the overview list is rather important. It contains three pieces of
information that we need to verify matches what we originally wanted in the query.
There are four fields in the query, all from the Household Inventory table: Item, AppraisedValue,
PlacePurchased, and PurchasePrice. These have been given the aliases Item, Appraised Value,
Place Purchased, and Purchase Price respectively.
Verification: Household Inventory is the correct table, the listed fields are the correct fields, and
the alias are also correct.
The field, Appraised Value, is the field that will be used for sorting, and the direction of the sort is
ascending (from the least value to the greatest). (The alias, Appraised Value, is used in place of
the field name, AppraisedValue.)
Verification: This is the correct field, and the sorting is in the correct direction.
The search condition applies only to Appraised Value and it restricts its values to $50 or more. Any
items worth less than or equal to $50 will not be shown when the query is run.
Verification: This is the correct field, and the search condition is also correct.
Verification: Since none of the fields are manipulated, we have a detailed query. This is correct.
If this were a query that we wanted to use, we would click the Finish button. The query wizard
would close, and a Table Data View dialog would open with the query output.
When you create a summary query with grouping of the results, enter the field by
which the grouping is done in Step 2 instead of Step 5.
Tip
When the summary query also contains a restriction on the values for each group,
use Step 3 to do this instead of Step 6.
Steps 5 and 6. (These are not used by the wizard, which uses Steps 2 and 3 instead.)
• Click Next in Step 5 and then in Step 6.
Step 7: Aliases.
1) Change PurchasePrice to Purchase Price.
2) Change AppraisedValue to Appraised Value.
3) Click Next.
As you go through the steps of the Report Wizard, use the mouse to move it so that
Tip you can see what effects your selections in the wizard have on the Report Builder.
Under Tables or queries, a drop-down list contains the tables and queries you have created.
Step 2: Select the table and its field for the report.
1) Select Query_Household Inventory from the Tables or queries drop-down list.
2) Move the list of Available fields to the list of Fields in report using the double right arrow
button.
Step 4: Grouping.
By selecting how the report should group the data, we have already selected the field, Date
Purchased, as the first sort option. We want the field’s sorting order to be ascending. No more
fields will be used in the sorting.
1) If you want to sort by more fields of the report, do so now.
a) Click the drop-down list below Then by to open the list.
b) Select the field you want to use to sort the report by. This sorting will be in addition to
the sorting by the Date Purchased field.
2) Click Next.
Page orientation can be either Landscape or Portrait. Which one you use depends upon the
number of fields contained in the report. For a large number of fields in the report, use the
Landscape orientation. For a smaller number of fields, Portrait will probably be the best selection.
Name the report. The suggestion given is Query_Household Inventory. This is the same name as
the query we used to create this report. Change Query_Household Inventory to Report_Household
Inventory.
You can create two types of report: static or dynamic. A static report is a Writer document which
can be modified like any text document, but any changes in the data in the underlying query will
not change the report. A dynamic report is much more flexible. Changes in the data of the
database will change the report the next time the report is run.
The Report Builder can also be used to modify the fields of the report. For example, the date
format for the Date Purchased can be changed and the Report saved. The next time the Report is
run, the data in this field will have the changed format. In a static report, you would have to change
the date format for each place this field appears in the report.
The final selection involves what should happen next. Selecting Modify report layout will open the
Report Builder so that the report can be edited. This is beyond the scope of this chapter. (See
Chapter 6 for how to use the Report Builder.) So, use the Default choice, Create report now.
Click Finish.
Figure 21 shows that sometimes the report needs to be edited once created. The layout did not
allow enough room for the word Refrigerator, and the space allowed for the field label Item is wider
than it needs to be. The data format might be changed as well, and this might require a change in
the length of this field. The fields containing currency amounts should be modified to the currency
being used in the Inventory database.
Writer
One very common database is the address book. Base will connect to several of them. Using
Writer with Base, you can print envelopes using the postal addresses in the address book and you
can send an email to several people in the address book at one time. This process is called mail
merge. It is explained in Chapter 11, Mail Merge, of the Writer Guide.
To include in a Writer document data that exists in one of our databases. we could look up the data
and type it into the document, but we might make a mistake in typing. By using Base with Writer,
we can place a field linked to the desired data in the document. Doing it this way guarantees the
data shown in the document will be as accurate as the data in the corresponding database. This is
explained in Chapter 14, Working with Fields, of the Writer Guide.
Using Writer, tables in text documents can be copied into a table in a database. A new table can be
created in the database including the data in the text document table. Or, a new table can be
created in the database without any data. Or, if the data in the table is arranged properly, this data
can be added to an existing table of a database. This is discussed in Chapter 7 of the Base Guide.
Calc
Base and Calc work together well. Using F4 or View Data Sources in Calc opens the Data
window. Data and column names can be copied from the data source to the spreadsheet that is
open in Calc. Data can also be copied from the spreadsheet to the data source. These methods
are discussed in the Calc Guide and in Chapter 7 of the Base Guide.
Impress
Base and Impress are not directly used together, but they can be used together in an indirect way.
Calc spreadsheets can be inserted into slides. So when you want to use data from a database in a
slide, you first copy the data into a spreadsheet and then insert this spreadsheet into the slide. This
is discussed in Chapter 7, Inserting Spreadsheets, Charts, and Other Objects, in the Impress
Guide.