Home

The Tables of a Database

 

Introduction to Tables

Imagine you create a list of people. The list can be started with names as follows: Bill, James, Hermine, and Khan. This type of list is considered one-dimensional because all of its items fit in one category. In order to create a more detailed list, you may want to include these people’s email addresses and probably other related information. If you include these additional pieces of information in the same category, the list may become confusing. To arrange the list, you would divide it in categories. Here is an example:

Name Email Address Phone Number Relationship
Bill bill@yahoo.com   Friend
James jamesemail.com (102)399-2893  
Hermine   (101) 447-8384 Cousin
Khan @Khan.com    

This type of display allows you to refer to a piece of information by its category. This is the basis of a table. A table is a two-dimensional list of items so that the items are arranged by categories. A complete or incomplete series of items that represent each category is called a record. Therefore, a table can be represented as follows:

In database development, a category is represented as a column. Sometimes it is also called a field. A record is represented as a row.

Database Object and Fields

A field is an object used to host, hold, or store a piece of information of a database. Before such an object can perform its function, it must first be created. In the strict sense, the most important or the most regularly used fields of a database are created on a table, but tables may not be the friendliest windows to present to a user for data entry. For this reason, fields can and should also be created on other windows.

The process of making a field available depends on the type of object it will reside on and probably how the field will be used. This leads to two categories of fields: those that can receive or store information and those that can only present or display it. All fields of a table, especially in Microsoft Access, are created to store data. On the other hand, fields on almost all of the other objects (queries, forms, reports) can be made of combinations of already existing fields of a table, or they can be created independently of any existing or non-existing data.

Table Layout

 

The Table's Tab

A table is presented as a rectangular window represented in the middle of the screen with a tab. As an option, you can remove the tabs and let the tables display without them. To do this, you can click the Office Button and click Access Options. In the left frame, click Current Database and, in the right frame, in the Document Window Options section, click the Tabbed Documents radio button and remove the check mark on the Display Document Tabs check box:

Access Options

After making the selection, you can click OK. You will be asked to close and reopen the database:

Which you should do.

On the left side of its top section, a table presents an icon Table Icon . The table icon provides a menu you can access when you right-click. The menu allows you to save or change the view of the table.

When a table displays with a tab, the extreme right section of the tab(s) shows a close button Close you can click to close the table.

The Table System Buttons

In Microsoft Office Access 2007, by default, a table in Datasheet View is represented with a tab, which prevents the user from moving it around. If you want, you can make the tables of a database appear as single documents. To do this, open the Access Options dialog box from the Office Button and click. In the left frame, click Current Database. Under Document Window Options in the right frame, you can click the Overlapping Windows radio button before clicking OK:

You will be asked to close and reopen the database.

A Table as a Datasheet

Although a table is primarily recognized as an arranged list of columns and rows, each column and each row intersect to create a rectangular box called a cell:

The cell is actually the object that holds data of a table. A cell holds only one piece of information. The database developer decides what type of information would go into a cell but the user types that information. Based on its arrangement of cells, a table is said to display in a datasheet layout or simply a datasheet (because its view is made of cells).

The Scroll Bars

If you start entering data into a table and there are more records than the height of the table can display, the table would be equipped with a vertical scroll bar. The vertical scroll bar would allow you to move up and down on the datasheet. This is useful if/when a table has more records than can be displayed all at once, and this will happen regularly. In the same way, if a table contains one or more records than the width of the table can display, the table would be equipped with a horizontal scroll bar:

Scroll Bars

The presence or absence of one or both scroll bars is automatically managed by the operating system and you should not be concerned with the management of the scroll bars. At the same time, if your users need to use a table, they know how to use a scroll bar.

Table Navigation Buttons

The lower left side of the table is made of four buttons used to navigate the table, one button used to create a new record, and a text box. Each button plays a specific role:

Button Name Role
First Record Allows moving to the first record of the table
Previous Record Allows you to move one record back (if there is one) from the current record
Current Record Displays the number representing the current record out of the total number of records
Next Record Allows moving you one record ahead
Last Record Allows moving you to the last record of the table
 New (Blank) Record Used to enter a new record on the table
 

Introduction to Table Creation

 

Table Creation

To have a table as part of your database, you must create it and you have various options. If you create a database using one of the local templates, it would provide you with a few tables that you can start using. To use a sample table, after starting a database, on the ribbon, you can click Create. Then, in the Tables section, click Table Templates to see a list of sample tables:

Tables Templates

From the menu that appears, you can click one. This would open a new table for you. You can then save it.

The Name of a Table

Like everything that is part of a database, a table must have a name that can be used to refer to that object throughout the database and in other files that can be linked to the table. There are two main ways you can specify the name of a table, either when you save it for the first time or if you decide to rename it.

To save a table you have just created:

  • You can click the Office Button and click Save
  • You can right-click the Table_X (such as Table1) tab and click Save
  • You can press Ctrl + S
  • You can start closing the table. You would be prompted to save the change (if its structure has been changed from the structure it had before it was opened)

If a table has not been saved before, you will be asked to provide a name for the table. A table can have almost any name: Employees, 2&&4DG, Pestes, verTT#@tg, etc. Because you and your users should be able to easily identify a table, there are suggestions you should follow when naming it:

  • The name of a table should reflect the kind of data it is holding
  • You can name a table with a few words, with spaces
  • You can use a prefix that identifies the table as such, a table. The name of a table would be preceded with tbl. If the name includes one word, such as Musicians, you can give the table a name like tblMusicians, another name would be tblStudents
  • If the name of the table reflects a combination of words, such as Bank Accounts or Students Academic Numbers, you should start each new word with an uppercase. Here are examples: tblBankAccounts, tblStudentAcademicNumbers, tblMemberRegistrations.
In our lessons, we will not use the convention of prefixing the name of a database object with three letters. For example, the names of tables will not start with tbl. We came to this decision because most other database environments, including Microsoft SQL Server, do not suggest this rule. Although the lack of this rule may create some confusion, because you will end up having a table and a form with the same name, we will strive to explicitly state what object type we are referring to. For example, we will avoid writing, "Open Employees" or "Open the Employees object". Instead, we will usually state, "Open the Employees table".
 

Table Management

 

The Tables in the Navigation Pane

Because the table is the primary object of a database, when you create a table and save it by giving it a name, Microsoft Access creates a section in the Navigation Pane and name that section after the table. In the same way, you can have as many sections as the number of tables on the database. Here is an example:

As we will see in the next lesson, some objects created that are based on the table would be listed under the table name in its category. Here is an example of two objects added to the section of a table named Customers:

Each section is expandable and collapsible. To expand a section, click the name of its section. to collapse a section, click the blue header of its section.

Once a table has been created and saved, it is represented in the Navigation Pane with an icon Table Icon and a name.

Opening a Table

The most regular operations you will perform on a table require that you open it first. To open a table, first locate it in the Navigation Pane then:

  • You can double-click the table
  • You can right-click the table and click Open

Any of these actions causes the table to display in Datasheet View in the central area of the screen. In the same way, you can open as many tables as necessary.

Closing a Table

After using a table, you can close it. Before closing a table, first select its tab. Then, to close a table:

  • You can click the close button Close on the right side of the tabs
  • You can press Ctrl + Shift + F4

Selecting a Table

In order to use a table, some operations require that you (or rather the user) first select(s) it:

  • To select a table in the Navigation Pane, simply click it
  • If you had opened many tables and they are displaying in the main area of the screen, to select one, click its tab or its title bar
  • If you have many tables displaying in the main area of the screen, you can press Ctrl + F6 continuously to switch from one table to the next until the desired one displays

Renaming a Table

We saw that, when or after creating a table, you must save it to make it part of your database. When saving it for the first time, you must give it a name. If the name of a table is not appropriate, you can change it. To rename a table, in the Navigation Pane, you can right-click the name of the table and click Rename.

Deleting a Table

If you have a table you don't need anymore, you can remove it from your database. Because you cannot delete a table if it is opened, you must first close it.

To remove a table from your database:

  • In the Navigation Pane, right-click the table and click Delete
  • In the Navigation Pane, click the table to select it. Then, on the ribbon, click Home. In the Record section, click Delete
  • In the Navigation Pane, click the table to select it and press Delete

In each case, you will receive a warning to confirm what you want to do. It is important to know that if you delete a table, because it is not a file, it does not go into the Recycle Bin: it is lost, including its records. Therefore, before deleting a table, make sure you really want to get rid of it. When in doubt, do not delete it.

Routine Operations on Table

 

Table Printing

The primary function of the table is to provide a means of storing and arranging information of a database. Nevertheless, you can print data of a table, especially if for example you are in a hurry and do not have access to another object. You can print data on a table whether the table is opened or not.

To print a closed table, locate it in the Navigation Pane and click it to select it, then click the Office Button, position the mouse on Print and select one of the three options. In the same way, if the table is opened in Datasheet View, click its tab to give it focus, then click the Office Button -> Print and select to print or to preview.

The Print menu of the Office Button presents three options:

  1. If you click Print, the Print dialog box would be presented to you. It allows you to specify the printer you want to use. Most of the time, the Name combo box will present the default printer; otherwise, you can select one:
     

     
    After specifying the printer, if you are ready to print, you can click OK. To customize the printing job, you can click Properties. A dialog box, whose contents depend on the selected printer, would come up. Among the various options you would have is that of specifying the orientation of the paper (Portrait or Landscape). Again, remember that different printers provide different features.
     
    After setting the properties of the printer, you can click OK. Once you are ready to print, you can click OK on the Print dialog box to send the job to the printer
  2. If you select Quick Print from the Print menu of the Office Button, the print job would be sent directly to the printer. Microsoft Access would use the default printer that is set in Control Panel and would use the previous settings that were set on that default printer
  3. If you select Print Preview, Microsoft Access would draw a print job on the screen for you. This allows you to see what the final job would look like on the paper. The characters on the screen may appear too small for you. To zoom in, you can click the middle of the window. To zoom out, you can click it again. Once you are ready to print, on the ribbon and in the Print section, you can click Print. This would send the print job to the printer

The Design View of a Table

 

Introduction

When we studied the creation of tables in Lesson 2, we saw how to create columns in the Datasheet View. Like the form or the report, the table can be presented in Design View. In fact, as you will see from now on, that's the best place to create the columns of a table. Instead of the Datasheet View, you can start a new table in Design View or you can modify an existing table in the Design View:

  • To start creating a table in Design View, on the ribbon, click Create. In the Tables section, click the Table Design button Table Design
  • To open an existing table in Design View, in the Navigation Pane, right-click it and click Design View
  • If a table is already opened, to switch it to Design View, right-click its tab and click Design View
  • If a table is currently opened, to switch it to Design View, on the right side of the status bar, click the Design View button Design View

Mostly you, the database developer, have access to the Design View of a table. The user will hardly, if ever, use that view.

A Table in Design View

A table in Design View is divided in two sections: one in the upper area and another in the bottom:

The top area is made of columns and rows. The columns are named Field Name, Data Type, and Description. When necessary, you will be directed to type or select something in one of the cells; the name of the column under which you must type or select will be specified in the lessons.

The lower portion of the window is made of two sections. The left section is made of two tabs labeled General and Lookup. Each tab contains two columns and various rows. The number of rows and the contents of cells depend on what is selected in the upper section. In our instructions, you will be directed when to do something in a tab or in a cell. As mentioned for the Properties window, the left column of the tabs in the lower section lists the names of characteristics. You cannot change the name of a property. The right column contains the values of the characteristics. When prompted to so so, you will create a new value, modify an existing value, or select one from a combo box. In some cases, a wizard will assist you with creating an expression as the value of a property.

The right side of the bottom section of the table is made of a read-only area that describes what is selected in one of the tabs of the lower-left section.

When given an instruction, you will be dealing with items in the top or the bottom section. To work on an item, sometimes you will be asked to click it to give it focus. You can then click the desired item. Another technique you can use to move from one section to the other is to press F6.

 

 

Home Copyright © 2008 FunctionX, Inc.