Chapter 4. Tables - creating a new table

To create a new table, double-click "Tables" in the list view.

We will now create the "authors" table. A tabledesign dialog will be displayed. As we define fields (columns), they will be listed in the box on the left hand side. It should be empty at this point. To create a column, press the "New Field" button. You will then be presented with default values in "Fieldname", "Fieldtype", "Size", "Primary Index" and "NOT NULL" fields. You should change the default values to describe the column you want to create.

Now define the columns for the "authors" table, using the values shown in the tabledesign window in Figure 4.1, “The tabledesign window”

To alter a definition of a column, select it in the left hand side list box and alter the values displayed in the upper right fields.

Figure 4.1. The tabledesign window

The tabledesign window

Important

Always define a unique / primary index in each table, otherwise you will experience some ugly side-effects when updating your data! The most convenient way to create a unique primary index is to use the "Auto Increment" field.

The following fieldtypes are valid:

There are two buttons in the upper left hand corner known as the "View Mode" buttons. The left hand button is the "Design" button, which should already be pressed, and the right hand one is the "Table Data" button. When you have completed your data-input, press the right button ("Table Data" button) at the top of the window.

Important

All high level widgets like tables, queries and forms operate in two modes, a design mode and a view mode. At the top of each window is a horizontal toolbar with at least two buttons. The left button selects the design mode and the right button the view mode.

After pressing the "Table Data" button, you will be asked if you want to alter the table. Confirm this question with the 'OK' button. The next dialog will prompt you for the name of the new table to which you enter "authors" and confirm by pressing the 'OK' button.

After that an empty grid is shown where you can interactively enter the data for each row. Start to enter the data in the row with the arrow. After the input of the first row, the last row will begin with a "*" and is empty. This is a new row where you can enter new data.

Figure 4.2. The tabledata window

The tabledata window

Enter the values for the first three rows as shown in the example. You will note that the vaules for the Auto Increment field "author_id" will be automatically generated.

Important

The bottom left hand corner of the table data window contains seven buttons and a field. These are the row selector buttons. The arrow buttons allow you to navigate between rows. The extreme left button (the '-' button) deletes the selected row. The button with the check mark on the right stores the changes made and you can add a new row by using the '+' button on the extreme right.

Now you can create the second table, "literature", on your own. Enter the first eight rows manually. As you can see, it is difficult to ensure that the manually input value in the field "author" of the "literature" table has an equivalent value in "authors" table.

The next figure shows how your "literature" table should look.

Figure 4.3. The "literature" table

The "literature" table

Important

You can print the table contents with the print button.