Sei sulla pagina 1di 11

Databases are created, maintained and accessed using a special type of software called a

Database Management System (e.g., Microsoft® Access® and FoxPro®). The Access®
Database Management System allows users to create databases that contain tables, as well as
other types of useful structures.

A database is a collection of interrelated files (tables). The records in each file are related to the
records in the other files, through the use of interlinked fields. For example, a student-record
database may consist of a personal file, a grades file and a medical file.

Using Access®, you can manage all your information from a single database file. Within the
database, you can divide your data into separate storage units called tables; view, add and update
table data using online forms; find and extract just the data you want using queries; and analyze
or print data in a specific layout using reports.

To store your data, create one table for each type of information you track. To extract data from
multiple tables, to create a query, form, or report, you must first define relationships between the
tables.

DATABASE STRUCTURES

A database has several structures. These structures include:

Tables
Tables provide the backbone to any database, as all data in Access® reside in a table (relation).
Access® tables are organized as a series of rows and columns called records (tuples) and fields
(attributes) respectively. Fields contain specific data types for each record (and are represented
by the columns). A record is a collection of related fields (and is represented by a row).

Forms
Forms assist the user in entering data into a table. They allow you to determine how records and
fields from a table will appear on the screen.

Queries
Queries are used to select specified data within a table. They allow users to ask questions about
the data in a table. Access® provides a query design wizard, and also allows you to develop
customized queries.

CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 155
Access® Workbook Database Structures

Reports
Reports are objects that produce output based on the data found within one or more tables. They
are used to arrange a set of data from a table. Access® provides a standard report design, as well
as it allows you to develop customized reports. Reports may be edited to include titles and
column headings, calculations may be done, as well as sorting of records.

Note: These structures are optional, with the exception of tables. A database must contain at
least one table, as this is where the actual data are stored.

156 CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua)
Access® Workbook Lesson 1: Creating a Database

LESSON 1: CREATING A DATABASE

Starting Access®

 Activate the Windows® Start menu.

 From the Programs menu, select the Microsoft® Office folder, then select Microsoft®
Office Access® 2007.

The Getting Started with Microsoft® Office Access® page appears.

Creating a Database

Let us create a database to organize Student Grades.

 Click the Microsoft® Office button.

 Click New. Alternatively, you could click Blank Database on the Getting Started with
Microsoft Office Access® page. The Blank Database task pane appears.

You are now prompted to name the database in the pane to the right of the screen.

CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 157
Access® Workbook Lesson 1: Creating a Database

 Type STUDENT GRADES in the File Name: text box and then click the open folder
icon to select your flash drive. The File New Database dialog box appears.

 Ensure that your flash drive is selected in the Save in: text box and then click OK to
return to the Blank Database pane.

 Click Create on the Blank Database pane.

A database window now appears displaying the name of the database in the Title bar. The Table
1: Table object window appears, in the Datasheet View.

Creating the STUDENT Table

 Select Design View from View in the Views group. The Save As dialog box pops up.

 Type STUDENT in the Table Name: text box.

158 CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua)
Access® Workbook Lesson 1: Creating a Database

 Click OK when done.

Note: The Table structure is created in the Design View. The Datasheet View allows you to
enter data into the table.

Defining the STUDENT Table Fields

The primary unit of information is called a field. Fields identify the individual data items within
a table, e.g., a field called Name and a field called Address. A group of fields is called a record.
For example, the group of fields about a student constitutes the record for that student.

Every field definition has three components:

Field Name: Access® allows a field name of up to 64 characters. However, it is best to keep
names short and meaningful. Use descriptive names.

Data Type: A data type must be specified for each field. The popular data types in Access®
are: Text, Memo, Number, Date/Time, Currency, AutoNumber and Yes/No.

Data Type Description Storage Size


Text Any letter, number, or symbol that has no numeric <= 255 characters
value. These characters are not mathematically
manipulated. Examples: John Doe, 178 Main Street.
Memo Any long character-based text. Memos hold up to <= 63,999 characters
63,999 characters in a single field. Examples:
sentences, paragraphs, descriptions, etc.
Number Any number that can be mathematically Byte – 1 byte, Decimal
manipulated, except mathematical manipulations – 12 bytes, Integer – 2
involving dollar amounts. Examples: 7, 18, -21, bytes, Long Integer –
0.625, 4.23 4 bytes, Single – 4
bytes, Double – 8 bytes
Date/Time Dates and times. Examples: 05/18/92, 12:34:09. 8 bytes
Currency Any number that is expressed as a dollar amount. 8 bytes
Examples: $0.53, $7.85, $389
AutoNumber Used to store sequential numbers automatically 4 bytes
entered by Access®.
Yes/No Holds only one or two values. Examples: Yes or No, 1 bit
True or False, On or Off.

Description: This is optional. The description appears in the status bar when a field is
selected during data entry (in the datasheet view).
CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 159
Access® Workbook Lesson 1: Creating a Database

 With the insertion point in the first row (first field) under Field Name, type Student Id#.

 Press the Tab key (the Enter key works just as well). The cursor moves to Data Type.

 Click on the Data Type selection arrow.

A list of available field types appears.

 Select Text.

 Place the insertion point in the Field Size box in the Field Properties list below.

 Delete 255 and enter 10.

Note: The field size property allows the user to set the maximum storage size of the data stored
in the field. We are not expecting the Student Id# to exceed 10 characters.

 Set Required to Yes in the Field Properties list.

This ensures that the field cannot be NULL (left empty).

The STUDENT table design should resemble the following:

Notice that this, the first field, is set as the Primary Key by default. We do not need to remove
the Primary Key since Student Id# is the field that we want as the Primary Key.

Setting the Student Id# as the Primary Key ensures that no two records have the same Student
Id#.

160 CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua)
Access® Workbook Lesson 1: Creating a Database

To remove a Primary Key, click Primary Key in the Tools group on the Design tab.

You will now continue to define the fields required for the STUDENT table.

 Move the insertion point to the second row (just below Student Id#).

 Type First Name then press Enter.

 Select Text as the Data Type, and set the Field Size to 15.

 Move the insertion point to the third row (just below First Name) and type MI (for
Middle Initial).

 Select Text as the Data Type, and set the Field Size to 1.

 Type Last Name in the fourth row. Set the Data Type to Text and the Field Size to 15.

 Enter the following fields in the same manner:-

Field Name Data Type Size


DOB Date Medium
Address Text 40
Telephone # Text 8
Email Text 25

The STUDENT table design should resemble the following:

You will now save these field definitions.

CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 161
Access® Workbook Lesson 1: Creating a Database

 Click the Microsoft® Office button and then click Save.

Closing the STUDENT Table

Since the table has been saved, you can now close it.

 Right-click on the STUDENT table tab and select the Close option.

Notice that the STUDENT:Table object appears in the navigation pane to the left of the screen.

Creating the COURSE Table

Let us look at another way of creating a table.

 Click Table in the Tables group on the Create tab.

 Select Design View from View in the Views group. The Save As dialog box pops up.

 Enter COURSE in the Table Name: text box and then click OK.

 Place the insertion point in the first row under Field Name and type Course Code.

 Select Text as the Data Type, and set the Field Size to 5. Set Required to Yes.

Notice that this, the first field, is set as the Primary Key by default. We do not need to remove
the Primary Key since Course Code is the field that we want as the Primary Key.

Setting the Course Code as the Primary Key ensures that no two records have the same Course
Code.

 Enter Course Name as the second field name.

 Select Text as the Data Type, and set the Field Size to 25.

Adding a Value List to a field

Note: A Value List is applied where there is a finite list of input options to any field (e.g., 2, 3,
4, 5 as possible credit hours for courses taken). It is a way to speed up data entry by
selecting from a drop-down list and to minimize data entry errors.

Let us add a Value List for the third field.

 Enter Credit Hours as the third field name.

162 CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua)
Access® Workbook Lesson 1: Creating a Database

 Select Number as the Data Type, and set the Field Size to Integer.

 Ensure that the Default Value text box is blank.

 Click on the Lookup tab and select List Box in the Display Control text box.

 Select Value List from the Row Source Type text box.

 In the Row Source text box, type the following list:

2;3;4;5

It is important to use separators between the values (a semicolon or comma may be used).

Your COURSE table design should resemble the following:

 Click on the General tab and type the following in the Validation Rule text box:

>1 AND <6

 In the Validation Text text box, type the following:

Enter an integer value ranging from 2 to 5.

Note: This validation ensures that only integer values from 2 to 5 are accepted. A value outside
of this range would generate an error message (stating the validation text).

Your COURSE table design should resemble the following:

CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 163
Access® Workbook Lesson 1: Creating a Database

 Enter Lecturer as the fourth field name.

 Select Text as the Data Type, and set the Field Size to 20.

 Save these field definitions and then Close the COURSE table.

The navigation pane now shows two objects: STUDENT:Table and COURSE:Table.

Creating the GRADE Table

 Click Table in the Tables group on the Create tab.

 Select Design View from View in the Views group. The Save As dialog box pops up.

 Enter GRADE in the Table Name: text box and then click OK.

 Enter Student Id# as the first field name.

 Select Text as the Data Type and enter 10 as the Field Size. Set Required to Yes.

This field is a Foreign Key (matches the Primary Key in STUDENT) that links the GRADE table
to the STUDENT table.

 Remove the Primary Key since a Composite Key will be created later.

 Enter Course Code as the second field name with Text as the Data Type and 5 as the
Field Size. Set Required to Yes.

164 CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua)
Access® Workbook Lesson 1: Creating a Database

This field is a Foreign Key (matches the Primary Key in COURSE) that links the GRADE table
to the COURSE table.

Let us add a Value List for the third field.

 Enter Grade as the third field name with Text as the Data Type and 2 as the Field Size.

 Click on the Lookup tab and select List Box in the Display Control text box.

 Select Value List from the Row Source Type text box.

 In the Row Source text box, type the following list:

A;A-;B+;B;B-;C+;C;C-;F

 Save these field definitions and then Close the GRADE table.

The navigation pane now shows three objects: STUDENT:Table, COURSE:Table and
GRADE:Table.

 Close the STUDENT GRADES database.

CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 165

Potrebbero piacerti anche