Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
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
Starting Access®
From the Programs menu, select the Microsoft® Office folder, then select Microsoft®
Office Access® 2007.
Creating a Database
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.
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.
Select Design View from View in the Views group. The Save As dialog box pops up.
158 CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua)
Access® Workbook Lesson 1: Creating a Database
Note: The Table structure is created in the Design View. The Datasheet View allows you to
enter data into the table.
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.
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.
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.
Select Text.
Place the insertion point in the Field Size box in the Field Properties list below.
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.
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#).
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.
CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 161
Access® Workbook Lesson 1: Creating a Database
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.
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.
Select Text as the Data Type, and set the Field Size to 25.
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.
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.
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.
2;3;4;5
It is important to use separators between the values (a semicolon or comma may be used).
Click on the General tab and type the following in the Validation Rule text box:
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).
CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 163
Access® Workbook Lesson 1: Creating a Database
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.
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.
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.
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.
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.
CaFSET (Antigua) Office Workbook. Written by Richard Lewis and Jessie Lewis © 2009 by CaFSET (Antigua) 165