The Visibooks Guide
to Base 2.0
The Visibooks Guide to Base 2.0
Copyright
Copyright © 2006 by Visibooks™, LLC. All rights reserved.
Trademarks and Disclaimer
Visibooks™ is a trademark of Visibooks, LLC. All brand and product names in this book are trademarks or registered trademarks of their respective companies.
Visibooks™ makes every effort to ensure that the information in this book is accurate. However, Visibooks™ makes no warranty, expressed or implied, with respect to the accuracy, quality, reliability, or freedom from error of this document or the products described in it. Visibooks™ makes no representation or warranty with respect to this book’s contents, and specifically disclaims any implied warranties or fitness for any particular purpose. Visibooks™ disclaims all liability for any direct, indirect,
consequential, incidental, exemplary, or special damages resulting from the use of the information in this document or from the use of any products described in it. Mention of any product does not constitute an endorsement of that product by Visibooks™. Data used in examples are intended to be fictional. Any resemblance to real companies, people, or organizations is entirely coincidental.
Table of Contents
Database Basics ... 1
Create a new database ...2
Create tables ...12
Create records...21
Create forms ...29
Create queries ...42
Create reports ...49
Working with Tables ... 65
Modify tables ...66
Create new tables...76
Specify data types...79
Specify field properties ...85
Edit records ...88
Find records ...91
Sort and filter records...96
TABLE OF CONTENTS ii
Working with Forms ...113
Modify forms ... 114
Add/delete records ... 119
Edit records... 121
Find records ... 123
Filter records... 126
Working with Queries ...131
Create queries... 132
Sort results... 141
Add criteria... 143
Database Basics
In this section, you’ll learn how to:
•
Create a new database
•
Create tables
DATABASE BASICS 2
Create a new database
1.
Start OpenOffice.org Base.2.
In the Database Wizard window, click Create a new database.DATABASE BASICS 4
3.
When the Save as window appears, create a new folder in the My Documents folder called Practice Base Files.Tip: To create a new folder, make sure the My Documents
folder appears as the Save In folder.
Then click the icon.
5.
In the File name box, type: Family.odbDATABASE BASICS 6
6.
Click the button.Identify database elements
Elements of databases
A database stores information in an organized way, and makes it easy to get information in and out.
Tables store data within the database.
Forms make it easy to put data into tables.
Queries pull out specific data.
Reports put data in an easily-read format.
Table
Query
Report Form
DATABASE BASICS 8
DATABASE BASICS 10
4.
Click Reports.DATABASE BASICS 12
Create tables
DATABASE BASICS 14
Name fields in Design View
1.
Click in the box under the Field Name column header:2.
Type:3.
Press the ENTER key on your keyboard.The Design View of the table should look like this:
DATABASE BASICS 16
4.
Click in the box under where you just typed First Name.Type:
Last Name
It should look like this:
6.
In the same way, create the following fields: CityZip
Phone Number
DATABASE BASICS 18
7.
On the Menu Bar, click File, then Save.8.
When the Save As window appears, type:My Family
in the Table Name box.
10.
When the alert window that reads No primary key appears, clickthe button.
Base will insert an ID field—the Key field—in the table:
DATABASE BASICS 20
11.
On the Menu Bar, click File, then Close.The key field
When the alert window popped up, and you clicked the button, Base added the ID field to the table.
The ID field is now the table’s primary key, or key field. That means it can’t contain any duplicates.
Every table should have a key field.
For example, if a hospital keeps a database, each patient can have a unique ID number in the key field.
Create records
1.
Double-click the table My Family in the Tables list.2.
Click in the box under the ID column header.3.
Type:DATABASE BASICS 22
4.
Click in the box under the First Name column header.5.
Type:Elvis
6.
Press the TAB key on your keyboard. The table should now look like this:7.
Type:Presley
then press the TAB key.
8.
Type:Baltimore
9.
Type: 21212then press TAB.
10.
Type:4105551212
then press TAB.
The table should now look like this:
Tip: Notice how the cursor in the row selector has moved down to the second (new) record.
DATABASE BASICS 24
Add new fields
1.
On the Menu Bar, click File, then Close.3.
When the menu appears, click Edit.DATABASE BASICS 26
4.
Click the box under Phone Number and type:State
5.
Press the ENTER key.6.
On the Menu Bar, click File, then Save.8.
Double-click the My Family table.9.
Click inside the new State field for the first record.10.
Type:DATABASE BASICS 28
11.
Press TAB until the cursor moves down to a new record.Record number 1 is saved and complete.
Create forms
DATABASE BASICS 30
3.
When the Form Wizard window appears, click the button.All the table fields should be added to the form:
DATABASE BASICS 32
5.
When the next screen appears, leave Add Subform unselectedDATABASE BASICS 34
7.
When the Set the name of the form screen appears, type: My Family Data Input FormDATABASE BASICS 36
8.
Click the button.Add a new record
1.
In the form window, click the button.DATABASE BASICS 38
2.
Click in the ID box, then type: 24.
Type: Bothen press the TAB key.
5.
Type:Diddley
then press the TAB key.
6.
Type:Richmond
then press the TAB key.
7.
Type:23220
then press the TAB key.
8.
Type:8005557890
DATABASE BASICS 40
9.
Type:VA
10.
Press the TAB key again.The form should progress to a new, blank record:
The old record has been saved.
DATABASE BASICS 42
Create queries
1.
In the Database list, click Queries. What’s a query?A query is a way to get specific information from the database.
DATABASE BASICS 44
3.
When the Query Wizard opens, double-click My Family.First Name in the Available Fields list.4.
Click the button.This should add the Last Name field to the Fields in the Query list:
5.
Double-click My Family.Phone Number.DATABASE BASICS 46
This should add the Phone Number field to the Fields in the Query list:
7.
When the Overview screen appears, in the Name of the query box type:Names and Numbers
8.
Click the button.The query is automatically saved and executed.
DATABASE BASICS 48
Create reports
DATABASE BASICS 50
2.
Click Use Wizard to Create Report.3.
When the Report Wizard window appears, click the Tables or Queries drop-down arrow.DATABASE BASICS 52
5.
In the Fields in report list box, click ID, then click the button. The ID field should be removed.The report wizard should now look like this:
DATABASE BASICS 54
9.
When the Sort options screen appears, click the Sort by drop-down arrow.Then click State in the list.
DATABASE BASICS 56
Choose layout and style
1.
When the Choose layout screen appears, make sure Default is selected in the Layout of data section.Then click the button.
View the report
1.
When the Create report screen appears, make sure the Title of report box reads:My Family
DATABASE BASICS 58
2.
Click the button.The report is automatically created, saved and opened.
It should look like this:
3.
On the Menu Bar, click File, then Close to return to the Family database window.DATABASE BASICS 60
Practice: Database Basics
1.
Open OpenOffice.org Base.2.
Create a blank database in the Practice Base Files folder called Library.odb.3.
Create a new table with these fields: IDAllow Base to create a Primary Key.
6.
Enter these data into the table to create the first record: Title: Ideas & OpinionsAuthor: Albert Einstein Genre: Nonfiction
Date purchased: 11/18/2005 Number of Pages: 384
It should look like this:
7.
Close the Books table.DATABASE BASICS 62
9.
Save it as Books Table Data Input. It should look like this:Use the form to enter information for four more books.
Tip: Feel free to make things up.
10.
Create a query that pulls out this information: TitleGenre
11.
Save the query as Quick Book Notes.12.
Run the query.It should look like this:
13.
Create a report based on the Books table.14.
Include all the fields of the Books table in the report, and sort the records based on Genre.DATABASE BASICS 64
15.
Name the report Book Inventory.It should look like this:
16.
Close the report.Working with Tables
In this section, you’ll learn how to:
•
Modify tables
•
Create new tables
•
Specify data types
•
Specify field properties
•
Edit records
•
Find records
•
Sort and filter records
WORKING WITH TABLES 66
Modify tables
1.
Open a web browser and go to:www.visibooks.com/books/base2
2.
Right-click the FlowerStore.odb link.3.
When the Save As window appears, open the Practice Base Files folder on your hard drive.Then click the button.
WORKING WITH TABLES 68
Open an existing database
1.
Start Base.WORKING WITH TABLES 70
WORKING WITH TABLES 72
Adjust table layout
2.
Place your cursor on the divider between the Phone Number and Fax Number column headings.WORKING WITH TABLES 74
3.
Double-click.The Phone Number column should resize to fit the widest piece of data in that field:
4.
Double-click the divider between the City and State column headings.The City field should resize to fit the data in it.
WORKING WITH TABLES 76
Create new tables
1.
Click Create Table in Design view.2.
In the first box in the Field Name column, type: Order IDthen press the TAB key.
It should look like this:
WORKING WITH TABLES 78
4.
When the Save As window appears, type:Orders
in the Table Name box.
5.
Click the button.6.
When the alert window appears, click the button.Specify data types
Assign the AutoNumber data type
1.
In the Data Type column beside the Order ID field, click the drop-down arrow.When the list appears, click Integer.
2.
Under Field Properties, beside the AutoValue field, click the drop-down arrow.WORKING WITH TABLES 80
3.
In the Description column, type:This is the Generic Order ID Number
then press TAB.
Tip: Filling in a Description is optional, but it helps you to
Assign the Date/Time data type
1.
In the Field Name column, in the second row, type: Order Datethen press TAB.
2.
In the Data Type column, click the drop-down arrow.WORKING WITH TABLES 82
4.
In the Description column, type: Date the order was placedAssign a Primary Key
1.
Right-click the Order ID field.2.
When the menu appears, click Primary Key.WORKING WITH TABLES 84
Specify field properties
1.
Click in the Order Date field.WORKING WITH TABLES 86
3.
In the menu of formats that appears, click 12/31/99.Then click the button.
The Order Date’s Format example field should now look like this:
4.
On the Toolbar, click the icon.Tip: If a Warning window appears, click the button.
The table design window should now look like this:
WORKING WITH TABLES 88
Edit records
1.
Open the Customers table.2.
Click inside the Customer Name field for record number 1, between the w and s in Andrews Floral.3.
Insert an apostrophe.5.
Type:2125554569
It should replace the previous text:
6.
Click in any other record.Tip: Remember—changed data in a record is saved when you move off that record.
WORKING WITH TABLES 90
Delete records
1.
Right-click the button for HomeVase’s record.2.
In the menu that appears, click Delete Rows.3.
When the alert window appears, click the button.Find records
Navigate records
1.
In the Customers table window, click the (Last Record) button.The cursor should be in the last record in the database:
2.
Click the (Previous Record) button.WORKING WITH TABLES 92
3.
Click the (First Record) button. The cursor should be in the first record.4.
Click the (Next Record) button.The cursor should be in the second record.
5.
Click the (New Record) button.Search for records
1.
Click the Company Name column header.The table should look like this:
WORKING WITH TABLES 94
3.
When the Record Search window appears, type:Love
in the Search for Text box.
5.
Click the button.The Customers table should now look like this, with Love Me True highlighted:
WORKING WITH TABLES 96
Sort and filter records
Sort in descending order
1.
Click the Company Name column header.The table should look like this:
WORKING WITH TABLES 98
Sort in ascending order
1.
Click the Customer ID column header to highlight the column.2.
On the Toolbar, click the (Sort Ascending) icon.Filter records
1.
Click in the State field for Pete’s Moss.Notice that the State is Virginia.
2.
On the Toolbar, click the (AutoFilter) icon.WORKING WITH TABLES 100
3.
On the Toolbar, click the (Remove Filter) icon.The Customers table should show its original contents:
4.
On the Menu Bar, click File, then Close to return to the FlowerStore database window.When to filter
Filtering records works like a query, bringing up specific information from a table.
But unlike a query, your filtering doesn’t remain part of the database.
When you perform a query and save it, the query remains with the database, even after you close it. Filtering does not.
Create table relationships
What are “relationships?”
Relationships are links that associate a field in one table with a field in another.
An example is a school database with two tables:
• Students • Classes
The Students table holds students’ names and addresses:
Students
Student Name Address
John Elm St. Jane Oak St.
The Math Class table holds information about the students in math class:
Math Class
Student Name Grade
John A Jane B
Both tables have a Student Name field.
By linking the Student Name fields, you make sure that John in the Students table is the same John listed in the Math Class table:
Students Math Class
Student Name Address Student Name Grade
WORKING WITH TABLES 102
Examine current table relationships
1.
On the Menu Bar, click Tools, then Relationships.The Customers table should appear in the Relationships work area:
3.
In the Add Tables window, double-click Employees.WORKING WITH TABLES 104
4.
Double-click Order Details.5.
Double-click Orders.6.
Double-click Products.WORKING WITH TABLES 106
Add relationships
1.
Place the cursor on the Title Bar at the top of the Employees table.3.
Click and drag the Orders table to place it between theCustomers table and Order Details table.
4.
Click the Order ID field in the Order Details table, then drag it and rest it on top of the Order ID field in the Orders table.WORKING WITH TABLES 108
5.
Release the mouse button.The relationships window should now look like this:
The Order ID field in the Orders table is linked to the Order ID field in the Order Details table.
The same Order ID number in both tables refers to the same order.
6.
On the Menu Bar, click File, then Close to return to theFlowerStore database window.
7.
When the alert window appears, click the button.Practice: Working with Tables
1.
Start Base.2.
Open the Library database in the Practice Base Files folder.3.
Create a new table in Design View.4.
Add the following fields in the new table (data type in parentheses):Author ID (Autonumber)
Author Name (Text)
WORKING WITH TABLES 110
5.
Set the Author ID field as the key field. The table design should look like this:6.
Save the table as Authors, then close it.7.
Open the Books table and view it in Design View.9.
Change the data type of the Date Purchased field to Date/Time, and its format to 12/31/99.10.
Save the Books table, then close it.Tip: An alert window will appear saying there was an error, due to changing the Date Purchased data type. Z
Click the button.
11.
Open the Relationship design window.12.
Add the two tables: Books and Authors.WORKING WITH TABLES 112
When you’re done, it should look like this:
14.
Close the Relationship design window and save the changes.Working with Forms
In this section, you’ll learn how to:
•
Modify forms
•
Add/delete records
•
Edit records
WORKING WITH FORMS 114
Modify forms
1.
Start Base, then open the FlowerStore database.3.
Right-click Customer Form.
WORKING WITH FORMS 116
Tip: Clicking Edit opens the form in Writer.
Change field position
1.
Click the Address 2 box to select it.WORKING WITH FORMS 118
3.
Click-and-drag the box to line it up with the other boxes.Release the mouse button.
Add/delete records
Add a new record
1.
Click the icon to toggle the view.2.
Click the (New Record) button.Fill in the following information:
Amy Moore Gifts & Buds
1214 Maryland Ave. Suite 13
Washington, DC 20001 2025556113
2025556114
WORKING WITH FORMS 120
Delete records
1.
Click the button to go back to record number 6, the one you just added.2.
On the Toolbar, click the (Delete Record) icon.Edit records
Navigate to a specific record number
1.
Click in the Record box.2.
Highlight the current record number, then type: 23.
Press the ENTER key.WORKING WITH FORMS 122
Edit data in a record
1.
Delete the contents of the Street Address field.2.
Type:476 New York Ave.
3.
Press the TAB key.The record should look like this:
Find records
1.
Click the button.2.
Click in the Company Name box to place the cursor there.WORKING WITH FORMS 124
4.
When the Record Search window appears, type:Floral
5.
Click the button.The window should look like this:
WORKING WITH FORMS 126
Filter records
1.
Click in the State box.The form should now look like this:
Tip: Notice the number of records now reads 1 of 2.
3.
On the Toolbar, click the icon.4.
On the menu bar, click File, then Close.WORKING WITH FORMS 128
The database window should now look like this:
Practice: Working with Forms
1.
Open a web browser and go to:www.visibooks.com/books/base2
2.
Right-click the Library2.odb link, and save the database in the Practice Base Files folder.3.
Close the browser and start Base.4.
Open the Library 2 database.5.
Using the Form Wizard, create a new form based on the Authors table, using all the fields.6.
Save the form as Author Information Input.7.
Using the form, enter information for John Grisham: Author ID: (Autonumber)Author Name: John Grisham Good Author? Yes
8.
Close the form.WORKING WITH FORMS 130
Working with Queries
In this section, you’ll learn how to:
•
Create queries
•
Sort results
•
Add criteria
WORKING WITH QUERIES 132
Create queries
1.
Start Base, and open the FlowerStore database.2.
In the Database list, click Queries.WORKING WITH QUERIES 134
4.
In the Add Tables window, click Customers.Then click the button.
This adds the Customers table to the query.
WORKING WITH QUERIES 136
Add fields to query
1.
Click the arrow in the first column’s Field box.The query design grid should look like this:
3.
Drag the First Name field from the Customers table to the second column of the query design grid.WORKING WITH QUERIES 138
The First Name field should appear in the design grid:
4.
Drag the Last Name field to the design grid. The design grid should look like this:Run the query
1.
On the Toolbar, click the icon.WORKING WITH QUERIES 140
Sort results
1.
In the Last Name field, click in the Sort row.When the drop-down arrow appears, click it, then click Ascending.
WORKING WITH QUERIES 142
2.
On the Toolbar, click the icon.The query should run, and sort the records alphabetically by Last Name:
3.
In the Last Name field, click in the Sort row, then click (not sorted).Add criteria
1.
In the query’s Customer table, scroll down to the State field.2.
Add the State field to the query design grid.WORKING WITH QUERIES 144
4.
Type:VA
5.
Press the ENTER key.It should look like this:
Tip: Notice that Base automatically surrounded the VA criterion with quotes. That’s because the State field stores text data. In database query language, quotes signify a string of text.
6.
On the Toolbar, click the icon. The query results should look like this:WORKING WITH QUERIES 146
Employ Boolean operators
What are Boolean operators?
Boolean operators are expressions such as AND, OR, NEITHER, and NOR that allow you to add multiple criteria to a query. They take their name from George Boole, the mathematician who first used them.
If you had a T-shirt store with an Base database, for instance, and you wanted to find out how many of your California customers had ordered blue T-shirts, you’d employ the AND operator in your query:
customers from California AND
who also bought blue T-shirts
If you wanted to see how many customers were from California (these California customers could have bought T-shirts of any color),
and how many customers bought blue T-shirts (these blue T-shirt customers could be from anywhere),
you’d employ the OR operator:
customers from California OR
Employ the OR operator
1.
In the State field, click in the Or row under the criterion VA.2.
Type:MD
then press the ENTER key.
WORKING WITH QUERIES 148
Tip: The two common Boolean operators are AND and OR. They’re easily confused. If you don’t know which to use, ask yourself the purpose of the query:
Do I want to find customers with a state of both Virginia AND Maryland?
No—a customer can’t be in two places at once.
Do I want to find customers with a state of either Florida OR Maryland?
That makes sense, so this query would use the OR operator.
3.
Click the icon.Employ the AND operator
1.
Remove the query criteria from the State field. Tip: Highlight them, then press the DELETE key.The design grid should be blank:
2.
Add the Company Name field to the query:WORKING WITH QUERIES 150
3.
In the Company Name field, click in the Criterion row.4.
Type:LIKE A*
then press the ENTER key.
Tip: An asterisk (*) stands for any character or combination of characters. For instance, Ap* would match Ape, Aptitude, Apparent, etc.
The LIKE keyword is used to search for a pattern.
5.
Click the icon.The query results should look like this:
The query shows all companies whose names begin with A.
7.
When the Save As window appears, type: Companies that begin with Ain the Query Name box.
8.
Click the button.9.
On the Menu Bar, click File, then Close.You should return to the FlowerStore database window.
WORKING WITH QUERIES 152
Practice:
Working with Queries
1.
Start Base.2.
Open the Library 2 database.3.
Create a new query in Design view based on the Authors table.4.
Add all the fields to the design grid.5.
Sort Authors Names in Ascending order.6.
Add the criteria Yes to the Good Author field.7.
Run the query.Its results should look like this:
Glossary
Boolean Operators
Boolean logic is a system of logical thought developed by George Boole. Boolean operators allow you to construct complex queries which can be understood by computers. The most common Boolean operators are “AND” and “OR”.
Data
A series of facts. When data is organized, it becomes useful information, which can be processed and used to draw conclusions.
Database
A collection of information organized into tables of data.
Field
A single unit of data stored as part of a database record.
Form
A database object primarily used to enter or display data.
Key Field
A field in a table that can contain no duplicates. The key field is each record’s unique identifier.
Query
A set of questions presented to a database to retrieve specific information.
Record
One row in a given table. In a relational database, records correspond to rows in each table.
Relationship
GLOSSARY 156
Report
Presents information retrieved from a table or query in a preformatted, easy-to-read way.
Select Query
A query that asks a question about the data stored in tables, and provides a result in the form of a datasheet.
Table
A collection of rows and columns that organize data.
Update Query
Where to Get Visibooks
If you liked using this book, and would like to use more like it, visit:
www.visibooks.com
Visibooks offers more than 30 titles on subjects such as:
• Computer Basics
• Microsoft Office
• Desktop Linux
• OpenOffice.org
• Web Site Layout
• Web Graphics
• Web Programming