Secondary Teaching Resources for I.C.T.
Databases

What is a database?
Access
How to make a new table
Data Types
Input Masks
Data Validation
Lookup values
Primary Keys
Queries
Aggregate Queries
Forms
Reports

Resources

Links

 

 

Databases

Creating a Table

When you first load Access, it will ask you if you want to create a new database, or load an existing one. Choose "Blank database" and then call the database "My Timetable", making sure that you store the file in a sensible place. You should now see a screen similar to this one. Move your mouse over the image to see some descriptions of the controls:-

Access 97, showing the database window. This is the "Table" tab, and is used to create, edit and open tables in your database. This is the "Query" tab, and is used to create, edit and open Queries in your database. This is the "Forms" tab, and is used to create, edit and open Forms for entering data or displaying information in your database. This is the "Reports" tab, and is used to create, edit and open Reports for displaying information held in your database. This button will open a "wizard" that can create a new table, query, form or report. These menus provide additional commands to use with your database.

We need to produce a new table, so click on the "New" button, select "Design View", and then click "OK"

New Table Dialogue box.

Start to enter the fields into your table, making sure that you don't make any mistakes.

Add the field names into the first column, and choose the correct datatype from the list in the second column. You will notice that the "Field properties" box at the bottom of the window shows different values depending on the data type that you have selected.

Entering the fields into the table design.

As you can see, Access has many options, and is capable of very complex database designs. The good news is that you dont need to use every one, but a well designed database would make use of a lot of these tools. Here is a list of some of the more useful ones:-

Field size

When you select a "text" data type, Access reserves a set amount of storage space to store the contents of the field for every record that you have entered. If you are storing data that contains words that are quite short (for example names) then you do not need to store many letters. Change the value of the field size so that it can store the longest string of letters that you can envisage using. In the names example, 15 is a reasonable setting and saves 70% storage space compared to teh size of 50.

When you select a "number" data type, here are the sizes that are available:-

Size

Meaning

Amount of space

Byte

Stores numbers from 0 to 255
(no fractions)

1 byte

Integer

Stores numbers from –32,768 to 32,767
(no fractions)

2 bytes

Long Integer

Stores numbers from –2,147,483,648 to 2,147,483,647
(no fractions)

4 bytes

Single

Stores numbers from
–3.402823E38 to –1.401298E–45 for negative values and from
1.401298E–45 to 3.402823E38 for positive values.

These numbers can have 7 decimal places.

4 bytes

Double

Stores numbers from
–1.79769313486231E308 to –4.94065645841247E–324 for negative values
and from
1.79769313486231E308 to 4.94065645841247E–324 for positive values

These numbers can have 15 decimal spaces.

8 Bytes

 

Byte, Integer, and long Integer only hold whole numbers. If you attempt to store 1.2 in a whole number field, it will be shortened to 1

Single and double are used with decimal numbers. The table above has some rather strange looking numbers in it, which are called "exponential format"

The number 3.40282E38 is the same as 3 followed by 38 zeros!

Format

Access can display certain data types in a special way, for example a date may be displayed as:-

20/08/02 or 20th August 2002 or 20/8/2002 or 20-Aug-02 as well as many more.

Use the drop downlist to choose the most appropriate format for each field.

Decimal places

Only applicable for single and double number types. Select a different value to alter the way the number is displayed.

Input Mask

An input mask will make Access check that the data you are entering fits into a set pattern

Click here to find out more about Input Masks.

Caption

When you come to actually enter your data into Access, the caption will appear next to the empty field. It is simply a label.

Default value

Sometimes, nearly every record in your database will have a similar starting value. To save time, Access allows you to set this default value so that the field will automatically have the correct value without you typing anything in.

Validation Rule and Validation Text

Access can check that the data you have entered is meaningful, for example it may check that a month value fits within the range 1 to 12

Click here to find out more about Validation Rules.

Required

Certain data will be essential if the record is to make sense. It would be silly having an antry into a diary if you didnt include a date.

If you set the required property to "yes", Access will not let you move to another record without setting a value.

Indexed

Access can set a value to be an index. this makes it much faster for Access to sort records or produce queries that contain this value. An Index can also prevent you from entering duplicate values, which would prevent you from typing in the same record twice.

You have three choices for the Index:-

Value

Meaning

No

(Default) No index

Yes (Duplicates OK)

The index allows duplicates.

Yes (No Duplicates)

The index doesn't allow duplicates

 

Lookups

We often need to select data from a list of values. To do this in Access we use a "Lookup".

Click here to find out more about Lookups.

Completing the table design.

Here is a complete list of the fields that you should have entered for your new database. Check each one carefully.

Once you have entered each one, you will need to save your table design.

Do not save it yet, there is something you must know first!

Click here once you have entered all of the fields

The Day field can have a lookup to a list of the numbers 1 to 10

Click here to return to the top of the page

The LessonNumber can have a lookup to a list of the numbers 1 to 5

It is good practice not to include any spaces in the field names, use a capital letter at the start of every word instead.

Click here to return to the top of the page

It would be possible to produce a lookup for the subject field, but we arent going to.

Click here to return to the top of the page

Click here to return to the top of the page

Click here to return to the top of the page

Click here to return to the top of the page

Click here to return to the top of the page

Click here to find out about Input Masks

Click here to find out about Data Validation

Click here to find out about Lookup values

Click here to find out how to save your table and add a Primary Key

Page last updated on October 25, 2002
Contact webmaster, Philip Waud by clicking here