Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

DATABASE DESIGN AND

DEVELOPMENT

OFFICE 2019

LEARNER WORKBOOK

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 1


Understand the difference between data and information

We first need to understand the basic difference between the


terms ‘Data’ and ‘Information’. The basic and unprocessed
information is called ‘Data’ whereas the processed data that is
ready to be used is called ‘information’. Information basically
adds meaning to the data. For example, if we have a list of
names without any headings showing a tick mark or a cross
mark against each name, it will be considered as data.
However, if we add appropriate headings to the list explaining
what the names and tick marks are for, it will become
information.

Adding, modifying and deleting data is known as managing data. Software that
allows you to manage data is called a database management system (DBMS).
Access is a popular DBMS.

Understand how a database is organised in terms of tables, records and fields

How does Access store data in a database? Data is stored in the form of tables
in an Access database. A table is nothing more than a set of rows and columns.
The graphic illustrates how data is stored in a table.

Before creating a database, you should


first consider the type of information that
you wish to store. Proper identification of
this data will help you decide the tables
that you need to create. Just as with
most projects, a good plan will also help
you create a database that is easy to
work with.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 2


Database Objects

An object is something that can be designed, selected and manipulated.


Tables, queries, forms and reports are all examples of objects.
Database tables consist of rows and columns of information, where the row
contains a record and the column becomes a record field.
A query is used to manipulate the data stored in the tables. The data can be
sorted (alphabetically in ascending A to Z, or descending Z to A order). The
data can be filtered to show only records containing a specific word or phrase,
or you can use the data to perform calculations. Being able to query the data is
the main advantage that computerised databases have over data that is stored
manually. The results of queries can be displayed on the screen and printed.
To enable users to use databases more easily, the data in tables is usually
accessed through a form. The form changes the way that the user accesses
and uses the records.
Reports are used to display the information that is stored in the database or
alternatively to show the results of a query in a more business-like way. The main
advantage of creating a report rather than just printing out the results of the
query is that with a report, users can add headings, sub-headings, dates, page
numbers and other types of formatting.

Open, close a database application

You can open Access through the Start menu on the Taskbar.

Exercise 1

1. Click the Windows button on the Taskbar.


2. Search for Access 2019.
3. Click the icon to open the program.

When you open Access, the Getting


Started with Microsoft Office Access
page is displayed. This page contains
options for creating a database. You
can create a blank database and
modify it later. You can also create a
database by using the Access
database wizard which guides you
through the steps in creating a database. The simplest method for creating a
new database is to use a blank access database.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 3


Exercise 2

1. To start creating a database, click Blank Desktop Database from


the options.
2. Click the Browse button next to the File Name field to
select the location where you want to save the file –
your computer in the Build-up Folder.
3. Name the new database as Properties.
4. Finally click the Create button.

Understand that field content is associated with an appropriate data type like:
text, number, date/time, yes/no

When you enter data in the fields of a table, you must set a data type for each
field. Microsoft Office Access 2019 provides ten different data types. You must
select an appropriate data type for the content of each field.

AutoNumber – this data type is used to generate a unique


sequence of numbers. This data type stores a number that
is incremented automatically when you enter a record.

Short Text – This data type is used to store a combination of


alphabetic characters and numbers. The data stored using
this data type cannot be used for calculations. You
normally assign this data type to fields, such as names and
addresses.

Memo – this data type is similar to the Text data type but
can be used to store lengthy text containing up to 65,335
characters. This data type is ideal for storing descriptions
and notes.

Number – This data type is used to store numbers, which can be used for calculations.
You can assign this data type to fields that will store numeric values, such as the quantity
and price of items.

Date/Time – This data type is used to store date and time values in different formats,
such as 20-Apr-08 or 04/20/08.

Currency – This data type is used to store numbers in the currency format, such as
$4,560.69. The data stored using this type can be used for calculations.

Yes/No – This data type is used to set Format property to True/False, Yes/No or On/Off,
which are the predefined formats. It also allows you to enter a custom format.
DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 4
Understand that fields have associated field properties like: field size, format,
default value

When you open a table in the Design view you will


see a section called Field Properties, which cannot
be seen in the Datasheet view. These field
properties define the way data is stored,
managed or displayed in the fields of a table.

Some of the more common field properties are


highlighted here. You will need to understand
these properties if you are to create efficient
databases.

Field Size – This property is used to specify the maximum amount of data that can be
stored in a field. For example, you cannot enter more than five characters in a field if
you specify the field size as 5. This property is applicable only for Text, Number and Auto
Number data types. Be aware that the increasing the field size you will increase the size
of your database and subsequently how fast your computer can search through it.

Format – This property is used to specify the format in which numbers, date/time, and
alphabetic characters are displayed. For example, in the MyContacts table, the
BirthDate field can be displayed as 20-Jun-75 or 06/20/75.

Caption – This property is used to set a name for a field as visible in the Datasheet view.
For example, the Birth Date field can be displayed as Birthday in the Datasheet view if
you specify Birthday in the Caption property of the field. This property is applicable for
Text, Number, Date/Time, Currency and Auto Number data types.

Default Value – This property is used to specify a value that is automatically displayed in
the field when you add a record to a table. For example, in a Publishers table, you can
specify High Growth as the default value for the Publisher Name field if the main
publisher is high Growth. This property is applicable, for Text, Number, Date/Time, and
Currency data types.

In Design View, you can use the upper section, Field Entry, to add or delete fields
and specify the data types of these fields. In the lower section of this view called
Field Properties, you can modify the properties of each field in the table.

Create and name a table and specify fields with their data types like: text,
number, date/time, yes/no
A new Database Table in Datasheet
View will appear.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 5


Exercise 3

1. Select the Design View option from the Views icon on the Home
tab on the Toolbar Ribbon. You will be asked to give the table a
name, key in MORTGAGES.

You will be faced with the screen shown above.

We are going to set up a database using the field titles below.

2. Firstly, you will be faced with a field called AutoNumber using a Primary Key.
Right click on the Key Symbol and remove.

3. Using the CAPS LOCK key we will enter the field names in
the Field Name column.

4. We will set the data type to Short Text fields except for
the AGE field which should be a number type and the
MORTGAGE field which should be set to currency.

Field Name Data Type Description Field Size


NAME Short Text name of customer 12
TOWN Short Text name of the town 20
TYPE Short Text type of property 15
AGE Number age of property Long integer
MORTGAGE Currency monthly mortgage payment 2 dec places

5. When this has been achieved we will click on the Datasheet View
button on the toolbar.

This is the datasheet view where you can enter your records.
DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 6
Set up and use Spell Checker to ensure accuracy in your work

You should always ensure your work is correct. The spell checker tool in Access
will help you check for accuracy but you should also proof read your data entry
as well.

To ensure the spell


checker will work
you will need to
select File tab from
the toolbar and
Options from the
menu.

Select the Proofing


option.

As we will be using UPPERCASE for our text entries ensure that the tick has been
removed, as shown and click OK.

6. We will now enter the details shown below:

NAME TOWN TYPE AGE MORTGAGE


SMITH BARRY BUNGALOW 25 £647.54
JONES PENARTH FLAT 10 £597.33
GREEN COWBRIDGE DETATCHED 5 £955.67
BROWN PENARTH TERRACED 30 £845.88
BLACK COWBRIDGE SEMI-DETATCHED 15 £698.32
WHITE BARRY FLAT 25 £563.45
MORGAN RHOOSE DETATCHED 30 £978.98
YOUNG PENARTH TERRACED 50 £720.67
PARRY COWBRIDGE FLAT 15 £578.45
CHARLES BARRY SEMI-DETATCHED 10 £605.38

7. Should any of the data be too long to fit in the field width, place the cursor
in the gutter between fields and double click. This will widen the column for
the longest word.

8. Run a spell check and also Proof-


read your work to find the errors.

9. Save the table. Keep the table


open.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 7


Add, delete records in a table

You can add or delete records from a table in Access simply by creating a new
record at the end of the database.

Exercise 4

1. Enter the following 2 new records

NAME TOWN TYPE AGE MORTGAGE


WEBSTER SULLY DETACHED 13 936.95
BAKER ST ATHAN SEMI-DETACHED 8 889.45

To delete a record highlight the row for that record and click the delete button
in the Records group of the Home Tab.

2. Delete the record for BROWN, PENARTH.


3. Keep the table open.

Add, modify, delete data in a record

You can modify or add data in a record simply by overtyping the data in the
relevant field that you wish to change.

To delete a record simply highlight the record in the left-hand margin of that
record and press the delete key on the keyboard.

Exercise 5

1. Amend the records for the following:

The Age of the Bungalow in Barry should be 27 years.


The Flat owned by Parry is in St Athan and not Cowbridge.

2. Delete the record for detached property owned by Green in Cowbridge.


3. Save the table and keep the database open.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 8


Create a validation rule for number, date/time, currency

We are now going to look at the field


attributes called Validation Rules and
Validation Text. These attributes can be
immensely useful by providing an automatic
check that any input data is valid. The
Validation Rule defines the limits for the field
and the Validation Text is the message that
will be displayed if a user attempts to input
data which is outside the set limits.

We can see here an example


where a validation rule has
been applied to a Currency
field. We might want to restrict
the business to transactions of
more than 50 pounds.

Exercise 6

1. Use the table called Mortgages.


2. Select the Home Tab and then View and
Design View.
3. Click into the Data Type for the Type field.
4. Set a Validation Rule on the Type field as
follows:

Validation Rule - <> Maisonette


Validation text - Category not available for this type of property

5. Select View and Datasheet View.


6. Try and change one of the records to Maisonette and see the error
message.
7. Save to your Build up folder and Close the file.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 9


Exercise 7

1. Open the database Golf Club.

The fields and data types have been set up as follows:

Field Name Data Type Field Property


Membership Number Number Long Integer
Last Name Short Text 25
First Name Short Text 25
Street Address Short Text 40
Town Short Text 20
County Short Text 30
Date Date/Time Short Date
Initial Fee Currency Currency
Monthly Dues Currency Currency
Membership Type Short Text 20
Handicap Number Long Integer

You will see that no information has been entered in the Membership Number
field.

Validation Rule for a Number


Suppose we want to limit the number of members to the club to only 40.

2. Switch to design view and for the field property of membership number
enter the following in the validation rule box.
>0 And <=40
This means that the number can be greater than 0, but equal to or less than
40. Save the design.

3. Switch to datasheet view and try to enter 50 as a number in the


membership number field. You should find that Access will not allow the
number as it is greater than 40. Try a number less than 40.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 10


Validation Rule for Date/Time

We do not want anybody in the table who joined the club before the year 2000
or after the year 2004.

4. In Design View, select the Date field.


Enter the following Validation Rule
>=31/12/1999 And <=01/01/2004

5. Enter a date of 12/06/1999 and observe the error reading.


6. Enter a valid date and save.

Validation Rule for Currency

You only want to accept initial fees between £200.00 and £850.00 and also
would like to edit the validation error message yourself to say Do not accept fees
of this amount.

12. In Design View select the initial fees field, and type in the following rule:
>200 And <850

7. In the validation text box type in the text Do not accept fees of this amount.

8. Enter an invalid amount in a new record and observe the error message,
which should be the one you created.
9. Save the database and close.

Sort records in a table, form, query output in ascending, descending numeric,


alphabetic order

When viewing a table in Datasheet view you can sort the records by any chosen
field.
Exercise 8

1. Open the database Jewellery from your user area.


2. Open the Customers table.
3. Sort the table in Ascending order of LastName.
4. Save the close the file.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 11


Understand what a primary key is

A primary key is a field that uniquely identifies records in a table. Each value in
the primary key field, such as 1 and 2 is different for every record.

Set a field as a primary key

Exercise 9

1. Open the file Exam Results from your Learner Drive.


2. Change to design view.
3. Set a Primary Key on the ID Number field.
4. Save the file, keep the database open for the next exercise.

Index a field (with, without duplicates allowed)

The arrangement of names in alphabetical order in a telephone directory makes


it easy for you to search for your name. In the same manner, it is easy to search
for records in a database if the records are arranged in a specific order.
You can create an index to arrange records sequentially in ascending or
descending order. An index helps you sort the records on a selected field and
facilitates subsequent searches for particular data in the table, therefore
allowing faster data access.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 12


Exercise 10

1. Open the file Exam Results from your Learner Drive.


2. Open the Results table in Design View.
3. Click the Indexes command in the Show/Hide group on the
Design tab to create an index.
4. In the Indexes dialog box, you first assign a name to the index. Type Name
in the Index Name cell and then press Enter.
5. Next, you select the field on which you want to create an index. Click the
down-arrow button in the Field Name cell.
6. Click the Name from the list.
7. The sort order is automatically selected
as Ascending. You can change the
order by clicking the down-arrow button
in the Sort Order cell. The button is
visible only when the Sort Order cell is
selected. For this exercise we will retain
this order.
8. Click the Close button.
9. Save and Close the database.

You have created an index in ascending order of Name in the Results table.

Add a field to an existing table

You can add field to database tables that are already created. You would
simply need to open the required database table and add the field.

Exercise 11

1. Open the database Properties from your Learner area.


2. Open the Mortgages table.
3. Select design view.
4. Add a field at the bottom of the last called PERIOD, set as Number data
type.
Enter the following data in the new field:
25, 20, 15, 20, 25, 20, 15, 20, 25, 20 respectively

5. Save and close the table.


6. Close the database.

Change width of columns in a table

To change the width of a column in a table simply click between the two field
headings and drag inward to narrow the column or outwards to widen the
column.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 13


Use the search command for a specific word, number, date in a field

If you have to find a record, based on a specific condition, from a large number
of records in a database, it can be time-consuming. For example, finding a
record with the address ’12 Anne Street’ in a telephone database containing
thousands of records will take a considerable amount of time. In this situation,
you can use the Find tool of Access to locate the record in the table.

To find a record, you must open the table in which the record is to be searched.
In this case, we will find the record in the Results table in the ExamResults
database.

Exercise 12

1. Open the database ExamResults from your Learner area.


2. Open the Results table.
3. Highlight the Name column.
4. Click the Find command in the Find group of the Home tab.
5. Find the record for oliver by keying this name into the find what box.
6. Click the drop down arrow and select the Name field.
7. Click Find Next.
8. You will be taken to the name oliver.
9. Amend the record to have a Capital letter for Oliver.
10. Save and close the table.
11. Close the database.

Exercise 13

1. Open the Membership database from your Learner area.


2. Open the Membership table.
3. Click on the Date of Birth column.
4. Click the Find command in the Find group of the Home tab. Here we can
enter the date of birth that we want to find.
5. Type the date 04/12/1977 in the Find What text box and then click the Find
Next button.
6. Click the Replace tab and type the date 06/12/1977.
7. Click the Replace button.
8. Save and Close the database

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 14


Apply a filter to a table, form

In Access, when you use a filter, you view only those records that you want to
see and the rest of them are hidden. This is much like the concept of using a
water filter to filter out dust particles. You can create a filter on a table, using the
Filter by Selection method.

Exercise 14

1. Open the Exam Results database from your Learner area.


2. Open the Results table.
3. Ensure you are working in Datasheet view.

To create a filter, you must select an occurrence of the value which you want to
use to restrict the view of records. In this case, we want to filter records based on
the Department field. We want to view records of results in the Accounts
Department only.

4. To filter records based on the Department ‘Accounts’, click the first


occurrence of Accounts.
5. Click the Selection command in the Sort & Filter group of the Home tab.
6. Now remove the ticks and tick only the Accounts option from the list in the
Sort & Filter group on the Home tab to filter the records of the Results table.
7. The details of only results in Accounts are displayed and the records of all
other results in other departments are hidden.
8. Keep the file open for the next exercise.

Remove the application of a filter from a table, form

Once you have viewed the filtered records, you can again view all records by
removing the filter that you added.

1. To remove the filter from the Results table, click the Toggle Filter command
in the Sort & Filter group on the Home tab.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 15


All the records in the Results table are now displayed.

We can apply a filter when viewing a Form too. Take a look at the Form shown
here. You can see at the bottom the indicator that shows that there are ten
records in the database. Next, we will select the field that shows the Type for this
record and apply a filter.

Exercise 15
1. Open the Results Form.
2. Click in the Department field on the word Computer.
3. Select Filter from the toolbar Ribbon.
4. Filter on Computer.
5. There are now only 6 records in the database for Computer.
6. Click Toggle Filter to Remove the filter.
7. Save and Close the database.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 16


Understand that the main purpose of relating tables in a database is to minimize
duplication of data

Relationships between tables in a database are used to reduce duplicated data.


Therefore, when building a database we often make use of multiple tables,
containing related data. We then define the way in which tables are related. This
helps eliminate duplicate data. For example, we might have one table containing
details of Suppliers and another table containing details of Products. Once we have
created these tables we have to tell Access how they are related.

Setting up the Linking Fields

As an example, we will use a college tutor database. The college uses a database
containing 2 tables, 1 about students and 1 about their personal tutors. The table for
the tutors uses the tutors initials as a code to identify each tutor. They make sure
that the codes are unique by adding extra letters if necessary, e.g. John Smith has
JS as a unique code, but Pete Brown and Philip Black would be referred to as PBn
and PBk. Each student is given a unique student ID code. In the tables below the
Primary Key fields are in Italics.

Personal Tutor Table Student Table


Tutor Initials Student ID
Tutor Forename Student Forename
Tutor Surname Student Surname
Department Date of Birth
Sex

There is a relationship between these two tables. Each student has a personal tutor,
so if we put a tutor Initials field in the student table it will identify the personal tutor for
each student.

Personal Tutor Table Student Table


Tutor Initials Student ID
Tutor Forename Student Forename
Tutor Surname Student Surname
Department Date of Birth
Sex
Tutor Initials

The Tutor Initials field is the only field that is duplicated. In the Personal Tutor
table, it is the Primary Key field. In the student table it is known as a Foreign Key
field. A Foreign Key field should always be a Primary Key field from another
table.
DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 17
Why use the Tutor ID a s a foreign key field in the student table, instead of the
Student ID as a Foreign key in the Tutor table?

Well we know that each tutor has many students, but the students only have one
tutor, therefore the tutor table would have had to have many students ID fields
added to its table, as shown below:

Personal Tutor Table Student Table


Tutor Initials Student ID
Tutor Forename Student Forename
Tutor Surname Student Surname
Department Date of Birth
Student ID Sex
Student ID
Student ID

The relationship we have built here is known as a ONE to MANY.


For ONE tutor there are MANY students.
The relationship between the tables is always expressed by a sentence in this
form. We cannot say that for one student there are many personal tutors as this
would not be true.

The relationship must always be set up from the ONE end to MANY end.
Remember - copy the Primary Key from the ONE end to the MANY end.

In the above example this means that the Initials of the Personal Tutor will be
listed in each record in the Student table. In the Student table the Student ID
field is still the Primary key. Tutor Initials is known as a foreign key in the student
table, because it is the primary key in a foreign table.

Understand the importance of maintaining the integrity of relationships between


tables

We can use this dialog box to apply ‘Rules’ to the relationships we create. If you
choose ‘Enforce Referential Integrity’ then Access prevents you from making any
changes to the tables that would compromise the integrity of the relationship. It
would, for example, prevent you from deleting records from the primary table
when there are matching records in a related table.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 18


Once a relationship’s line has been selected you can choose ‘Edit Relationship’
to show the familiar Edit Relationships dialog box or you can choose ‘Delete’ if
you want to remove the relationship altogether.

Creating a Relational Database

Exercise 16

1. Create a new Database and call it Barry College.

2. Create two tables containing the information below, one called Personal
Tutor, and one called Student.

Personal Tutor Table

Field Data Type Field Property


Tutor Initials (Primary Key) Short Text Field size 3
Forename Short Text Field size 15
Surname Short Text Field size 15
Department Short Text Field size 20

Student Table

Field Data Type Field Property


Student ID (Primary Key) Short Text Field size 3
Forename Short Text Field size 15
Surname Short Text Field size 15
Date of Birth Date/Time Short Date
Sex Short Text Field size 1
Tutor Initials (Foreign key) Short Text Field size 3
Note

When setting up the different tables the relating fields in each should have the
same data type and field properties as shown in red.

3. Close and save the tables before entering the data, as the relationship
must be set up before any data is entered.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 19


4. On the Database Tools tab click relationships icon.

5. Click the Show Table icon on the toolbar and then double-click the names
of the tables you want to relate, and then close the Show Table dialog box.

6. Arrange the tables so that the Tutor table is on the left and the Student
table is on the Right, and stretch them so that you can see all the fields.

7. Drag the tutor initial field in the tutor table to the tutor initial field in the
student table.

8. The Edit Relationships dialog box is displayed. Check the field names
displayed in the two columns to ensure they are correct.

9. Tick the Enforce Referential Integrity check box. This will ensure that the
user does not enter Tutor Initials in the Student table that do not already
exist in the Tutor table.

Referential Integrity

Rules that you follow to preserve the defined relationships between tables when
you enter or delete records. You cannot delete fields that joint tables as long as
links to another table exist.

10. Click on create.

The ONE to MANY link is drawn with representing the MANY end.

11. Close the relationship window and click Yes to save.

12. You will now enter the data in the appropriate tables, making sure that you
enter the data in the tutor table first, as nothing can be entered into the
tutor’s initial field in the student table until the details have been entered
into the tutor table.

Tutor Table:

Tutor Initials DO AR KB BE JS
Forename Donna Andy Karen Brenda Joyce
Surname Owen Royle Baker Emett Selby
Department Computing Accounting English Mathematics Music

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 20


Student Table:

Student 101 102 103 104 105 106 107 108


ID
Forename Susan Mark Sally Alan Amy Dave Nia James
Surname Jones Smith Morgan Wade Long James Price Thomas
DOB 12/7/82 3/8/83 21/5/78 7/6/79 15/4/80 19/9/81 25/10/80 28/2/81
Sex F M F M F M F M
Tutor DO AR KB BE BE JS DO AR
Initials

Delete a Relationship

And now after all that hard work we are going to delete the relationship.

13. Close any tables that are open.


14. Switch to the Database Tools tab. You can press F11 to switch to the
Database window from any other window.
15. Click the Relationship icon on the toolbar.
16. Click the relationship line for the relationship you want to delete (the line will
turn bold when selected), and then press the Delete key on the keyboard.
17. Save and close the file.

Understand that a query is used to extract and analyse data

A query is used to extract and analyse data from a database. Data can be
extracted from one table of a database or several tables. A query allows you to
choose the fields and specify the criteria that could refine your search. It is
possible to store a query in a database making it available for use again, if you
have to search for records based on the same criteria.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 21


Create a named single table query using specific search criteria
Run a query

In Access, you can either use the Design view or the Wizard method to create a
query.

Exercise 17

1. Open the file Properties from your user area.

2. Click on the Create tab of the Toolbar Ribbon


and select Query Design from the options. The
query window will appear. Highlight the
Mortgages table and click Add and Close.

3. Double click the heading Mortgages and the


fields will be highlighted. Click into the highlighted area and drag down to
the layout on below.

4. In the field NAME column on


the SORT row choose
Ascending from the options.

5. On the Criteria row in the Type


column insert the word FLAT.

6. Ensure that the Design tab is


selected from the Toolbar
Ribbon. To run the
query click on the red
exclamation mark on
the toolbar.

7. The records will now be sorted in alphabetical order of NAME for properties
of the FLAT type.
8. Close down the query by clicking on the X in the right hand corner of the
query box. You will be asked if you wish to save the query. Save as NAME
ASCENDING FLAT.
9. Save and Close the file.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 22


Create a named two-table query using specific search criteria

In this exercise we will create a query that uses two tables to produce a list of
Students with the tutor CJC. We want the list to include the Department for these
students. We will use the Design view for creating the query.

Exercise 18

1. Open the Barry College database from your


Learner area.
2. Reset the relationship and enforce referential
integrity.
3. Go to the Create tab on the toolbar Ribbon.
4. Select Query Design from the Query group on the
ribbon.
5. Add the Personal Tutor and Student tables and
close.
6. Double-click the Tutor Initials and Department fields from the Personal Tutor
table and the Student ID from the Student table.
7. Sort the Student ID in ascending order.
8. On the criteria row under Tutor initials enter DO.
9. Run the query.
10. Save the query as DO.
11. Save and close the file.

Add criteria to a query using one or more of the following operator: = (Equal), <>
(Not Equal to), < (Less than), <= (Less than or equal to), > (Greater than), >=
(Greater than or equal to)

These are the most commonly used operators used in queries.


Exercise 19

1. Open the Auctioning Items database from your Learner area.


2. Create a query using all the fields from the Items table.
3. Sort the Datein column in Ascending
order.
4. The criteria for the Actual Price
column is >100 (greater than 100).
5. The criteria for the Status column is
AVAILABLE.
6. Run the query.
7. Save the query as Available.
8. Save and close the file.
DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 23
Add criteria to a query using one or more of the following logical operators:
AND, OR, NOT
To specify multiple criteria in a query, you must use logical operators such as
AND, OR, NOT. Using the AND logical operator, you can retrieve records that
satisfy all the criteria. For example, to retrieve the records of the employees from
the Employee table who work in the HR department and earn a salary of less
than £10,000, you must use the AND logical operator.
In addition to specifying multiple criteria, you can display the result of a query in
ascending or descending order of a field. For example, you might want to
display the results of the Employee Salary query in ascending order of Employee
Name field. To display records in ascending or descending order, you can use
the Sort feature of Access.

Alternatively, you can use the OR logical operator to retrieve records that meet
any one of the specified criteria. For example, if you want to retrieve records of
employees who live in Chicago or New York, you should use the OR logical
operator while specifying the criteria. To use the OR logical operator, you must
specify the alternative criteria in the row labelled OR.

You can use the NOT logical operator to exclude records that match the
specified criterion. For example, if you want to exclude records of employees
who have the Job Title of MD, then you should use the NOT logical operator
while specifying the criteria under the Job Title column. You can do this by
entering MD with the prefix NOT or the symbol <> in the row labelled criteria.

Exercise 20

1. Open the Barry College database from your Learner area.


2. Select the Create tab from the Ribbon.
3. Select the Query Design command in the Queries group of the Create tab.
4. Add the Personal Tutor Table and the Student Table and Close.
5. Double-click the Tutor Initials and Department fields from the Personal Tutor
table.
6. Double-click the Student ID field from the Student
table.
7. Sort the Student ID in ascending order.
8. On the criteria row under the Tutor initials field enter
DO.
9. On the or row under the Tutor initials field enter JS.
10. Run the query – there should be three records for
Student ID’s.
11. Save the query as JSDO.
12. Save and close the file.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 24


Use a wildcard in a query, * or %, ? or - #

Apart from mathematical operators, a query can use characters known as


wildcards. Wildcards are used in queries to narrow down the result. Some of the
commonly used wildcards are *, %. ? or _.

For example, if you were looking for all customers who were in Purchasing, then
you would use Job Title as Purchasing* - this would find both Purchasing
Managers and Purchasing Representatives. You can also use Purchasing% to
look for Job Titles in Purchasing – this would return the same result. The wildcard
characters * and % match any number of characters, but the character *
cannot be used with the % character in the same expression.

# matches any numerical entry. If you were looking for a range of numbers from
200 to 299 you would use 2##.

Exercise 21

1. Open the Golf Club database from your Learner drive.


2. We will now create a query using some of the wildcards mentioned above.
3. Select the Create tab on the Toolbar Ribbon.
4. Click the icon for Query Design.
5. Add the Membership table and close.
6. Take all the fields down.
7. In the County column on the criteria row enter V*.
8. Run the query – this will pick up all records for the V of Glamorgan.
9. Save the query as Vale.
We will use the same database for the next query.

Exercise 22
1. Select the Create tab on the Toolbar Ribbon.
2. Click the icon for Query Design.
3. Add the Membership table and close.
4. Take all the fields down.
5. In the Membership Type column on the criteria row enter F?????
6. Run the query – this will pick up all records for Family.
7. Save the query as Family.
We will use the same database for the next query.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 25


Exercise 23

1. Select the Create tab on the Toolbar Ribbon.


2. Click the icon for Query Design.
3. Add the Membership table and close.
4. Take all the fields down.
5. In the County column on the criteria row enter *W*.
6. Run the query – this will pick up all records containing the letter W.
7. Save the query as W.
8. Save and close the file.

Edit a query: add, modify, remove criteria

You can modify or remove the criteria already specified for a query. To modify
criteria in a query, open the query in the Design View and select the criteria to
be modified. Then, type in the new criteria over the existing one and press the
Enter key on the keyboard. To remove criteria in a query, again, open the query
in the Design View and select the criteria to be removed. Then, press the Delete
key on the keyboard. After modifying or removing a query, click the Save
button on the Quick Access Toolbar to save the changes made to the query.

Exercise 24

1. Open the Country database from your learner drive.


2. Open the Population query in Design View.
3. Modify the criteria in the population field to be >50 (greater than 50).
4. Run the query.
5. Save the query.
6. Save and close the file.

Exercise 25

1. Open the Mailing database from your learner drive.


2. Open the query 1 query in Design View.
3. Delete the criteria in the Establishment Type column.
4. Run the query.
5. Save the query.
6. Save and close the file.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 26


Edit a query: add, remove, move, hide, unhide fields

Along with the existing fields in a query, you can also add new fields to view
additional information. You can also remove a field.

Exercise 26

1. Open the Deletion database from your learner drive.


2. Select and open the Staff Ages query in Design View.
3. Add the Age field to the query.
4. Run the query.
5. Save the query.
6. Close the database file.

You might decide that you want to change the order in which the query
presents the columns. You can change the order of the columns by simply
dragging columns from one place to another.

Exercise 27

7. Select and open the Staff Ages query in Datasheet View.


8. Move the Staff ID field so that it is the first field in the query.
9. Save the query.
10. Keep the database open for the next exercise.

In addition to adding a field, you can


remove a field from a query if you don’t
want the information related to that field
anymore. All you need to do is click
above the Field heading and press the Delete key on the keyboard.

Exercise 28

1. Select and open the Staff Ages query in Design View.


2. Delete the Age field from the query.
3. Run the query.
4. Save the query.
5. Keep the file open for the next exercise.

When you are working with a query you can also hide fields that are not relevant
at the time. To hide a field just click the tick box, located at the bottom of the
field in the Design View, once so there is no tick showing. To unhide a field, just
click the tick box so the tick is showing again.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 27


Exercise 29

1. Select and open the Prices query in Design View.


2. Hide the Product Code field from the query.
3. Run the query.
4. Save the query.
5. Select and open the Prices query.
6. Unhide the Product Code field in the query.
7. Run the query.
8. Save the query.
9. Keep the file open for the next exercise.

Understand that a form is used to display and maintain records

You have seen that the Datasheet view of a table is used to enter and display
data. However, sometimes you might find the Datasheet view format difficult to
use. Access has a feature that allows you to create an easier to use format,
called a form.

Look at the two formats. The Form format displays


the details of records, one by one, from a table.
Therefore, it helps you concentrate on one record
at a time.

The Datasheet format, on the other hand, displays


multiple records on the screen. However, this
format looks difficult to read and can divert your
focus from the specific record you want to look
at.

A form is a means of entering and viewing data. It makes for good


communication between the user and the table. Forms are based on tables
and queries and users interact with forms directly. This makes data access and
maintenance easy. You can use a form to view or add one record at a time in a
table. You can even add colours and graphics to make the form more
interesting. You can also use different text styles to improve the appearance of
the form.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 28


Create and name a form

A database must be opened before you begin to create a form.


Exercise 30

1. Open the Deletion database from your


learner drive.
2. Select the Create tab from the toolbar
ribbon.
3. Select Form Wizard icon.
4. Add the Stock table.
5. Take all the fields over using the >> symbol in
the centre.
6. Click Next.
7. Select Columnar click Next.
8. Name the form Stock and click Finish.

The completed form shows there are 5


records.

9. Keep file open for next exercise.

Use a form to insert new records

Exercise 31

1. Use the Deletion database.


2. Open the Staff form.
3. Add a new member of staff Marge, Jones, staff ID 4, age 37.
4. Save the Staff form.
5. Save and close the file.

Use a form to delete records

To delete a record in form view, scroll through the records until you find the one
you wish to delete. Click on the left side of the record and press the Delete key
on the keyboard.

Exercise 32
1. Open the Exam Results database from your learner drive.
2. Open the Results form.
3. Delete record no 9 for Natalie.
4. Save the form.
5. Save and close the file.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 29


Use a form to add, modify, delete data in a record

We are going to modify the membership fee for a member.

Exercise 33

1. Open the Membership database from your learner drive.


2. Open the Membership Form.
3. Find record 3 Jason Perry.
4. Amend the membership Fees to £2,500.00.
5. Save the Form.

Exercise 34

We are going to add missing data to a form.

1. Continue using the Membership Form.


2. Find the record for Donna Jameson
3. Add the town field as Branford.
4. Save the Form.

Exercise 35

We are going to delete data from a record in a form.

1. Continue using the Membership Form.


2. Delete the Membership Fees for Ann Forsyth.
3. Save the Form.
4. Keep the database open for the next exercise.

Add, modify text in headers, footers in a form

Here are the three main sections that are displayed when a form is opened in
the Design View.

Form Header – the form header section is used to display information such as the
heading or the form or the logo of an organisation. The information provided in
the Form Header appears at the top of the form.
DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 30
Form Footer – the form footer section is used to display information such as date
and time at the bottom of the form.

Detail Section – the detail section of the form is used to display the records of a
table.

Consider an example where the logo of an organisation has to be added to the


top of a form. This involves adding an image.

Exercise 36

1. Use the Membership database.


2. Open the Membership Form in Design View.
3. Select the Form Header.
4. Click the Logo icon in the Header/Footer group of the Design tab.
5. Locate the image People from your learner drive.
6. Insert the image People.
7. Ensure the image does not overlap the heading text.
8. Return to Form View.
9. Save the form.
10. Keep the database open for the next exercise.

Understand that a report is used to print selected information from a table or


query

When you see a mailing label, an invoice, or a sales summary, you find data
presented in suitable format. These are different examples of a report. Reports
can be created using data from a table or a query in different formats and are
suitable for producing printed output. A report can include selected data from
many tables and queries at once and perform calculations on that data, with
neatly formatted results as the output.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 31


Printing data directly from a Sales table may not make any sense to a sales
manager. The sales manager might want to view the data along with totals and
sub-totals. Access provides a feature for presenting data in meaningful formats.
This feature is called reports.

The Report Wizard is a tool that you can use to


create a report in Access. You can use data from
a table or a query to create a report.

Create and name a report based on a table, query

Exercise 37

1. Use the Membership database.


2. Select the Create tab from the toolbar ribbon.
3. Select Report Wizard from the Reports group on the ribbon.
4. Select the Membership Table.
5. Take all fields over and click Next.
6. Click Next.
7. Select Tabular and Landscape and click Next.
8. Name the report Membership.
9. Click Finish.
10. Save and close the file.

You can create a report from a query in the same way.

Change arrangement of data fields and headings within a report layout

It is easy to use the Report Wizard to create a report. The wizard, however, does
not give you much freedom to experiment with the appearance of the report. A
simple report created using the Report Wizard might look like what you see in the
graphic above.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 32


We will look at changing the position of a field and adding a picture.

Exercise 38

1. Open the CIA database from your learner drive.


2. Open the Suppliers Report in Design View.
3. Click into the Report Header.
4. Select the Design tab on the ribbon.
5. Click the Logo icon and find the image Snake from your files.
6. Click Insert and move the picture to the left of the heading Suppliers.
7. Move the Supplier Ref column so it becomes the first column.
8. Widen the Supplier Ref, Supplier Name and Telephone columns and narrow
the Supplier Address column.
9. Go back to Report View to see the changes you have made.
10. Save the report and close the database.

Present specific fields in a grouped report by sum, minimum, maximum,


average, count, at appropriate break points

A report is used to present data from a table in a formatted manner. Grouped


data is useful for comparison and analysis. For example, in the graphic shown
above, the yearly sales data of a company is grouped for each month. This
makes the comparison of monthly sales easy.

You can group records on any field in a report. For example, in a sales report,
you could group the sales using the month field, so it shows all sales by month.
When grouped, records are shown together under a heading called Group
Header. This heading has the name of the field on which the records are
grouped. Like Group Headers, reports can also have Group Footers. You can
show useful information, such as the sub-total for the grouped records, at the
end of the group in Group Footer.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 33


Exercise 39

1. Open the Mailing database from your learner drive.


2. Click the Create tab from the ribbon.
3. Select Report Wizard.
4. Select the Table Mailing List.
5. Take over all fields except the Address (1-4) and Postcode fields.
6. Group by Establishment Type.
7. Sort in ascending order of Department.
8. Click Next.
9. Select the Stepped and Landscape layout.
10. Name the Report Grouped Data and then click Finish.
11. Check the report.
12. Go to Design View and ensure all field are wide enough to take the
contents.
13. View the Report.
14. Save and Close the Report.
15. Save and close the file.
We have seen how we can make our reports extremely informative by arranging
the data correctly. When dealing with numerical data it is often useful to add
extra information to a report in the form of group totals and averages. Access
offers some valuable tools to help with this.

Exercise 40

1. Open the Jewellery database from your learner drive.


2. Click the Create tab on the ribbon.
3. Click the Report Wizard icon.
4. Select the Customers table and add all fields.
5. Click Next.
6. Group the Report by Last Name.
7. Sort by First Name ascending.
8. Click the Summary Options button and Sum the Customer Spend and click
OK.
9. Click Next and Layout is Stepped and Landscape.
10. Click Next and Select your desired layout.
11. Click Next and Report name Customers and Finish.
12. Save and Close the database.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 34


Add, modify, text in headers, footers in a report

We will now see how we can add useful information at the top and bottom of a
report in such a way that the same information is automatically printed on each
page of the report.

Page Header and Footer are the sections of a report that display information at
the top and bottom of a page.

Report Header and Footer are the sections of a report that display information at
the beginning and end of a report.

You would use Report Header when you want to print information only once in
the beginning of a report. Generally, you will use Report Header to print
informaiton such as the title of a report. You would use Report Footer to print
informaiotn such as a summary and grand totals at the end of a report.

You can use Page Header and Footer when you want to print information at the
top and bottom of each page in a report. For example, the headings and fields
can be the page header and the date and page number can be the footer.

We will now amend the Report header and insert the date and page number for
a report.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 35


Exercise 41

1. Open the Auctioning Items database from your learner drive.


2. Open the Sales Report in Design View (you may have to right click the
report to view in Design View).
3. Click into the Report Header text label and amend the heading to read
Salespersons.
4. Make the font Red and point size 26.
5. Click into the Page Footer and choose the Design
tab from the ribbon and click the insert page
number icon.
6. Select the format Page N of M.
7. Select the position Bottom of Page (Footer).
8. Select Alignment Right.
9. Click OK.
10. Highlight =Page etc and select Times New Roman font size 9.
11. Move the box to line up with the date field already in the footer.
12. View the report.
13. Save and Close the database.

Import a file into Access

You can import CSV or Excel type files into access.

Exercise 42

1. Open the file Jewellery from your learner drive.


2. Select the External Data tab from the Ribbon.
3. Select the Excel icon and browse for the file Town in your learner drive.
4. Click the Open button.
5. Click Next, ensure you tick First row contains headings, click next, no primary
key, click next until you get to the end and then name the table Town.
6. View the Town table that you have just imported.
7. Save and close the file.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 36


Export a table, query output in spreadsheet, text (.txt, .csv), XML format to a
location on a drive

You can also choose to export the output of a table or query as a text file, a
spreadsheet or an XML file.

Exercise 43

1. Open the Country database from your learner drive.


2. Open the Euro less than 10 query in Datasheet View.
3. Select the External data tab on the toolbar ribbon.
4. Click the Text file command in the Export group.
5. The Export file dialog box is displayed. Click the Browse button.
6. In the File Save dialog box enter the name Query Output.
7. Click the Save button.
8. The Export Text Wizard screen is displayed. Notice that the Delimited radio
button is selected.
9. Click the Next button.
10. This screen allows you to choose the character to separate the fields. The
comma is selected by default. Click the Next button.
11. A dialog box with the export filename is displayed. Click the Finish button.
12. Go to your Build up folder open the query output file in notepad
13. Click the Close button.

Change the orientation (portrait, landscape) of a table, form, query output,


report. Change paper size

You may decide that your document would look


better when printed in a different orientation or
on a different size of paper. You will need to
select the File tab and Print option and then Print
Preview.

You can then select from the toolbar for


Landscape or Portrait buttons to set the
orientation. You can check the effect of these
changes in the Preview mode.

You can also send your documents to PDF or EPS files instead of printing them.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 37


Print a page, selected record(s), complete table

You can print your table in the usual way.


Select tab, go to the Print option and
select the Quick Print option from the
displayed list to print all the pages or you
can select the File tab and click the Print
option in the menu. This will open the Print
dialog box which offers some useful
options.

You will already be familiar with this Print dialog


box but when we use it to print a database
table you will notice some interesting changes.
Apart from being able to choose between
printing the whole document and just selected
pages, you can also choose to print only
selected records. When this option is selected,
the print will ONLY include those records that
were SELECTED prior to choosing Print.

We have now seen how we can print tables. We can also print reports and
forms. Just like before, you can use the Print Preview option to see how the form
will appear on the printed page.

Print the result of a query

You can print the results of a query by clicking the Microsoft office button,
moving the mouse to the Print option and then clicking Quick print. If you wish to
make changes to the paper size or the orientation of the page, select Print
preview you can now change the orientation to Landscape and export the file
to PDF.

Print specific page(s) in a report, print complete report

You can print entire reports or specific pages of a


report by selecting the Print option from the Office
button and selecting the Print option. Click into the
selection area and select page 1 to page 1.

Exercise 44

1. Open the Mailing database from your learner drive.


2. Open the Mailing List report.
3. Print page 1 only of this report to pdf format with the filename Page1.
4. Close the database.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 38


Set a database password

To ensure that you do not get unwanted


access to your database you can set a
password. You need to Open the
Database and select Open Exclusive.

You the need to select File and Encrypt


with Password.

This will give you the option to Set and


Verify your password.

Exercise 45

1. Open Exclusive the Mailing database.


2. Select File and Encrypt with Password.
3. Set and verify the password as Mail.
4. Close the database.
5. Reopen the database to ensure the password has been set.
6. Provide screen shot evidence of the password screen.
7. Close the database.

DATABASE DESIGN AND DEVELOPMENT Donna Owen December 2020 39

You might also like