Base: Creating basic databases and tables

When databases became available for the personal computer in the mid-1980s, they quickly gained a mystique as the ultimate productivity applications. Despite their widespread use, in some ways they have never lost that mystique -- so much so that many desktop users will stretch the use of spreadsheets to cumbersome lengths rather than consider setting up a database. Fortunately, Base makes setting up a database easy, giving you a more efficient way of handling data than a spreadsheet.

Setting up a basic database in Base consists of two parts: configuring the database, and adding at least one table to it.

Choosing and registering the database

To begin customizing a database, select Database from the initial screen or File -> New -> Database from the menu. Either way, the Database Wizard opens.

Your first step is to choose a database with which to work. You have three choices, but what they are is obscured slightly by the wording and order of choices in the wizard:

  • Create a new database: Make a new database in Base's native HSQL format
  • Open an existing database file: Edit a Base database that is already created.
  • Connect to an existing database: Make a new database in one of the other formats supported by Base. Besides formats such as MySQL and Oracle, Base also supports several other formats on the free desktop, including Mozilla, Evolution, and KDE address books. Another option is to choose an or MS Excel spreadsheet, which is useful for when you want to explore Base quickly or when you want to convert a growing spreadsheet into a database.

What happens on the next page of the wizard depends on your choice. If you are creating a new database, you are asked if you want to register it so that you can use data from it in other OpenOffice applications (a subject for another article). Since this option has no drawbacks and is convenient, usually there is no reason not to register the new database.

By contrast, if you open an existing database, you move directly to Base, while if you choose another database format, you need to enter the path to it and other information that will allow you to use the database -- anything from a simple password to the porter, server URL, and database driver.

These variations are too numerous and too different from each other to discuss here in any more detail, but if you click the Help button on the second page of the wizard, you will find detailed instructions on how to deal with each type of supported format.

Once the connection to the database is entered, in some cases, such as Evolution address books, you will be unable to continue in the wizard, and will have to edit directly from Base, regardless of your preference -- although why this limitation exists is unclear.

When you have registered a new database or connected to an existing one, you have the option of editing the database. In some cases, you only have the choice of editing in Base, but with new databases and some others, such as spreadsheets, you also have the option of editing tables in another wizard. Whenever possible, you should consider using the wizard, especially if you are unfamiliar with databases.

Setting up tables

Tables are the basic structure of a database. Although they resemble spreadsheets, they are organized somewhat differently. Instead of being organized into cells that can either be part of a larger record or individual containers of data, tables are always organized by rows. Each row is a single record, and each column is a separate field within each record. Since each record is unique, setting up a table consists of adding columns to it.

When you create a new database in the wizard, you may have the option of creating tables in a wizard, depending on the type of database you are using. If you choose the wizard, then you start with selecting the fields (that is, columns) for the database. The wizard provides dozens of default fields, dividing them first into Business and Personal categories, and then into secondary categories, such as Customers, Deliveries, or Addresses.

Each secondary has a list of commonly used fields. To add one of these defaults to your database, all you need to do is select it in the Available Fields pane, and use the arrow keys to move it to the Selected Fields pane.

The first entry in the Selected Fields pane is the first column on the left of the table. You can use the up and down arrows on the right of the Selected Fields pane to change the position of fields; for instance, you might want to ensure that the LastName field in a table listing customer addresses was the first field, because most people will be using it to find a specific record.

You can also use the arrow keys on the left of Selected Fields pane to move a field back to the Available Fields pane. A single arrow button moves the selected record, while a double arrow moves all records.

Pressing the Next button takes you to a page on which you define what sort of information goes into each field. After selecting a field on the left side of the page, you can edit:

  • The name of the field: Usually, you won't want to change the name, but you might want to edit the default name. For instance, if you are doing an address book for only the United, you might want to alter the default PostalCode to the more colloquial Zip.
  • Type: The format of the data in the field. This is analogous to the number format of a spreadsheet cell, and includes many of the same choices, such as Text, Number, and Date/Time. Another useful type is Yes/No.
  • Entry required: Whether the field is compulsory, or can be left blank.
  • Length: The number of characters allowed in the field. This characteristic can be restricted to control the size of the database, or as a guide to correctness. For example, in a field for North American phone numbers, you might want to restrict entries to ten characters.

On the next page you set the primary key, or unique identifier for each record. The easiest choice is Auto-value, in which case each record is identified by a number. However, you may prefer to generate a primary key from a single field, or a combination of fields.

Whether using fields is a practical choice depends, of course, on choosing a combination that will be both unique for each field, and meaningful to the database's users. For example, the address field might be unique, but is probably not the handiest way to refer to a record. By contrast, a combination of LastName and FirstName would be handy and reasonably unique, but not as much as using LastName, FirstName, and Address.

Finally, on the wizard's last page, you can give the entire table a unique name, and choose your next step: Adding records into the database, editing the table, or creating a form (another topic for another day).

If the table wizard is not available because of your database format, you can create tables from within Base by selecting Create Table in Design View. Here, you can work within an actual table-like format, which may be easier for you to conceptualize what you are doing. The orientation, though, is different in the wizard, in that the top field will become the first field on the left of the table.

Once you enter the field name, you can choose its format type from a drop-down list in the second column. Below the table, the current field's properties are listed for editing. Unlike in the wizard, editing from design view gives you the option of adding a default value and a format example. In the table itself, you can add a description, a sort of mouse-over help similar to that you can add using the Validity tool in a spreadsheet.

Another difference between the design view and the wizard is that, in the design view, you only create the primary key when you go to save the table -- when it appears as the first field in the table.

Next Steps

At this point, you have a basic database with one or more tables. Should you want to add another table or to edit you can choose whether to work in design view or the tables wizard from the Tasks pane in the top middle of Base.

Alternatively, you can select a table from the Tables pane in the lower middle of the window, and select Open from the context menu to edit it in design view.

However, creating a database and tables are only the beginning of working with Base. You can easily copy and paste information from an open Base table to other applications, but to gain the full efficiency of working with databases, you should also know how to set up forms, queries, and reports. In upcoming articles, I'll cover all three, explaining what they are and how to use them.

base.png52.33 KB
base-wizard1.png49.54 KB
base-wizard2.png43.71 KB
tablewizard1.png68.38 KB
tablewizard2.png70.22 KB
tablewizard3.png72.05 KB

-- Bruce Byfield (nanday)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hey thanks for posting this.

radio controlled boats's picture

Hey thanks for posting this. Have been looking all over for it. Found you through Google and I couldn't be happier.

Waiting for the rest of the content patiently....

furicle's picture

I think the issue with databases for most people is demonstrated neatly with this article (and everybody else's database how-to's I've seen). It talks about how to set up a database, but doesn't tell you why you'd want to really.

I wonder if this is a case where 'starting in the middle' makes the most sense. i.e. Start with the reports and forms so people see why they want a database and what they can do with one, then back track to show them how to create the database.

It's kinda like teaching someone how to drive without them ever being in a car before.

furicle is 100% on target

Anonymous's picture

Many years ago my father tried to teach me how to use a spread sheet and failed. I knew it was a powerful tool, but I had no idea what I would do with it and so didn't have the incentive to learn. More recently I've found uses for them, taught myself how, and have been happy and productive ever since.

Today, I know a database is a powerful tool, but what will I use if for? My incentive to read the rest of these articles, and thereby learn about base, is limited. Fast forward me to the future please . . . where I have a need.

2 Dimensional Data vs. 3 Dimesional Data

GridIron's picture

I know what you mean furicle. Many small businesses think the can survive using plain old spreadsheets. Many times, I agree it's possible.

Now is it efficient? I think of spreadsheets as piece of paper with only 2 dimensions. At the same time the data is 2 dimensional as well; there's not too much you can do with the data.

When you start to sell the idea of a 3 dimensional spreadsheet as a database (I know, not exactly, but almost), then businesses or whomever can start to understand that data can be stored once and in one place. I much more efficient choice over dozens of spreadsheets.

Great Writeup

Anonymous's picture

Great content.. good read.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot