Sie sind auf Seite 1von 17

Databases:

Practice activities
Databases: Practice activities DM00

IT Learning Centre ii
DM00 Databases: Practice activities

How to Use this User Guide


This handbook accompanies the taught sessions for the databases course series.

The Exercises
Some exercises, particularly those within the same section, assume that you have
completed earlier exercises.

Text Conventions
A number of conventions are used to help you to be clear about what you need to
do in each step of a task.
 In general, the word press indicates you need to press a key on the
keyboard. Click, choose or select refer to using the mouse and clicking
on items on the screen. If you have more than one mouse button, click
usually refers to the left button unless stated otherwise.
 Names of keys on the keyboard, for example the Enter (or Return) key, are
shown like this: ENTER.
 Multiple key names linked by a + (for example, CTRL+Z) indicate that the
first key should be held down while the remaining keys are pressed; all
keys can then be released together.
 Words and commands typed in by the user are shown like this.
 Labels and titles on the screen are shown l i k e t his .
 Drop-down menu options are indicated by the name of the options
separated by a vertical bar, for example Fi l e| Pri nt . In this example you
need to select the option P ri n t from the Fi l e menu or tab. To do this, click
when the mouse pointer is on the Fi l e menu or tab name; move the
pointer to Pr i nt ; when P ri n t is highlighted, click the mouse button again.
 A button to be clicked will look l i k e t hi s .
 The names of software packages are identified like this, and the names of
files to be used l i k e t hi s .

Software Used
Access 2013 or similar
These exercises were designed using Access 2010, but you will be able to do most
if not all the activities using other version of Access.

Files Used
C ar Sc h e dul e .x l s x
M e e ti n gR o om B o ok i n gs . x l s x
I n t Ex _ S ta ff C ar s _ 0 1. ac c db
I n t Ex _ S ta ff C ar s _ 0 2. ac c db
I n t Ex _ S ta ff C ar s _ 0 3. ac c db
I n t Ex _ S ta ff C ar s _ 0 4. ac c db
Int Ex_Meet ingRooms01.accdb
I n t Ex _ M ee ti n gR o o ms 02 F ew R ec or ds .a c c d b

iii IT Learning Centre


Databases: Practice activities DM00

I n t Ex _ M ee ti n gR o o ms 03 I m po rt e dD at a .ac c d b

Revision Information
Version Date Author Changes made
1.0 April 2012 Pamela Stanworth Created
2.0 October 2014 Pamela Stanworth Updated

Copyright

Pamela Stanworth makes this document and the accompanying PowerPoint


presentation available under a Creative Commons licence: Attribution-
NonCommercial-ShareAlike CC BY-NC-SA. pamela.stanworth@it.ox.ac.uk
Screenshots in this document are copyright of Microsoft.
The Oxford University crest and logo and IT Services logo are copyright of Oxford
University and may only be used by Oxford University members in accordance
with the University’s branding guidelines.

IT Learning Centre iv
DM00 Databases: Practice activities

Contents
1 Introduction ............................................................................. 1
1.1. What You Should Already Know ......................................................... 1
1.2. Using the Practice Activities ............................................................... 1
1.3. Trusting the Database Files for the Exercises ....................................1
2 Exercise: Car Loans - Design a Database ................................ 2
2.1. Scenario .............................................................................................. 2
2.2. Design ................................................................................................ 2
2.3. Build ................................................................................................... 2
2.4. Enter Some Data ................................................................................ 2
2.5. Sample Solution ................................................................................. 2
3 Exercise: Car Loans - Import From Flat File .......................... 3
3.1. Scenario .............................................................................................. 3
3.2. Review the Data ................................................................................. 3
3.3. Import the Data ................................................................................. 3
3.4. Integrate the New Data Into the Database Tables ............................ 3
3.5. Sample Solution ................................................................................. 3
4 Exercise: Car Loans - Queries, Forms and Reports ................ 4
4.1. Build Forms ........................................................................................ 4
4.2. Build a Navigation Form ................................................................... 4
4.3. Use the Forms .................................................................................... 4
4.4. More Interactive Forms ..................................................................... 4
4.5. Protect Against Accidental Data Editing ........................................... 4
4.6. Build Queries ..................................................................................... 5
4.7. Build Reports ..................................................................................... 5
4.8. Sample Solution ................................................................................. 5
5 Exercise: Meeting Rooms - Collect Data From Filing Cards ... 6
5.1. Scenario .............................................................................................. 6
5.2. Review the data .................................................................................. 6
5.3. Design and Build ................................................................................ 6
5.4. Enter Some Sample Data ................................................................... 6
5.5. Meeting Room Booking System - 6 Sample Data Cards ................... 7
5.6. Sample Solutions ............................................................................... 8

v IT Learning Centre
Databases: Practice activities DM00

6 Exercise: Meeting Rooms - Import and Re-organise Data


From a Flat File........................................................................... 9
6.1. Scenario .............................................................................................. 9
6.2. Review the Data ................................................................................. 9
6.3. Import the Data ................................................................................. 9
6.4. Retrieve the Staff Details ................................................................... 9
6.5. Retrieve the Room Booking Details .................................................. 9
6.6. Housekeeping .................................................................................... 9
6.7. Sample Solution ............................................................................... 10
7 Further information ................................................................ 11
7.1. Getting extra help .............................................................................. 11
7.1.1. Clinics ................................................................................................... 11
7.1.2. About Lynda.com ................................................................................ 11
7.1.3. About the ITLC Portfolio online .......................................................... 11
7.2. About the IT Learning Centre ........................................................... 11
7.3. About Academic IT Services ............................................................. 11

IT Learning Centre vi
Databases: Practice activities

1 Introduction
Welcome to the Databases: Practice activities!
These exercises are intended to provide extra practice for anyone who has
participated in the series of database courses taught by the IT Learning Centre.
If you are away from the class, you can get help by email from your teacher or
from help@it.ox.ac.uk.

1.1. What You Should Already Know


This session is one of a series that cover the important aspects of building and
managing a database.
We will assume that you have already attended all the courses (or equivalent),
and that you are familiar with creating tables with suitable fields, creating and
editing a query, and creating basic forms or reports using the wizards. The
exercises call on a variety of skills and techniques covered during the taught
course series, not necessarily in the order that they are taught.
The computer network in our teaching rooms may differ slightly from that which
you are used to in your College or Department; if you are confused by the
differences please ask for help from the teacher or demonstrator(s).

1.2. Using the Practice Activities


Here we set a series of tasks, for you to carry out using your own copy of
Microsoft Access.
If you are contemplating attending the taught courses, these tasks will give you an
idea of what to expect. After attending the courses, you could use these tasks to
assess yourself, or for extra practice or consolidation.
Bear in mind that there are often two or more ways of achieving a task, and you
may well have hit upon an entirely sensible alternative to that suggested here.
This handbook sets out a series of tasks for you to tackle. There are not supposed
to be any tricks – just take each step at face value. The tasks are deliberately
worded rather vaguely, as is common in real projects. You will need to use your
imagination and your judgement about some aspects.
On finishing, you must decide for yourself whether you are satisfied with your
final product and the time/trouble it took you, or whether you need further help
or training.
You may be interested to look at the sample files provided, which suggest some
possible solutions to the tasks set.

1.3. Trusting the Database Files for the Exercises


Please note that Access only trusts files if they have been saved in a “Trusted
Location”. You may recall, from the taught courses, that in our teaching rooms
the home dr i v e H :\ has been designated an Access Trusted Location. If you make
copies of the files for these exercises, and save them on your own computer in a
location that is not trusted, you may not be able to carry out all the activities
described.

1 IT Learning Centre
Databases: Practice activities

2 Exercise: Car Loans


- Design a Database
2.1. Scenario
A department of the University has a small car, which members of staff may use
for work purposes. They need a database to keep track of who uses the car and
any related expenses they incur.

2.2. Design
Design a database for recording who books the departmental car and when, the
car mileage and any claims for the cost of petrol, parking and similar related
expenses.
Draw a freehand diagram showing the tables and fields needed, and the
relationships between the tables.
Note: some expenses are not associated with a particular journey, such as paying
for a windscreen to be replaced.

2.3. Build
Build the database in Access. Create all the tables, with suitable fields. Give the
fields suitable properties. Create joins between the tables.
Print a copy of the Relationships Diagram.

2.4. Enter Some Data


Enter 2 or 3 records into each table, working in Table Datasheet View, to confirm
that the table relationships work as required. Invent some plausible data values.

2.5. Sample Solution


I n t Ex _ S ta ff C ar s _ 0 1. ac c db

IT Learning Centre 2
Databases: Practice activities

3 Exercise: Car Loans


- Import From Flat File
3.1. Scenario
Further to the departmental car scenario mentioned in chapter 2 above, we
discover that in the past the departmental administrator has been keeping a note
of times when staff have used the car, and their expenditure. It would be useful to
include this past information into your new database.
The previous data was managed using Excel.

3.2. Review the Data


Open C a r Sc h e dul e.x l s x provided and examine the data in the three worksheets.
One worksheet gives the names and details of members of staff. One worksheet
gives the occasions when members of staff used the departmental car. The other
worksheet gives the claims that members of staff have made, for expenses related
to using the car.
Think about how this data corresponds to your database design. Adjust your
tables and fields if necessary. Adjust the spreadsheet data if necessary.

3.3. Import the Data


Import each worksheet into the database as a separate table. In the Import
Wizard, take care over the data types of each field.

3.4. Integrate the New Data Into the Database Tables


Use append queries to append the data from each imported table to one of
your tables (notice that the column headings in the Excel worksheet do not
exactly match the field names in the Access tables).
You will need to match up some of the records from one table with corresponding
records from another table.

3.5. Sample Solution


I n t Ex _ S ta ff C ar s _ 0 2. ac c db

3 IT Learning Centre
Databases: Practice activities

4 Exercise: Car Loans


- Queries, Forms and Reports
4.1. Build Forms
Build some forms to make it easier to enter data when someone borrows the
departmental car.
You will need:
A form for adding information about each member of staff
A form where a member of staff can book the car for future use, or add details
of a recent borrowing
A form where a member of staff can claim for expenses connected with using
the departmental car

4.2. Build a Navigation Form


Some of the staff are not used to working with databases. Make your database
simpler for them to navigate:
Create a welcome form
Make sure that they will see this when they first open the database
Provide some buttons for them to click, as an easy way to find each of the
forms they need
Conceal the tables, queries and other database objects so they do not distract
users
Remember you yourself will need a way of finding all the tables, forms, queries,
reports etc so you can continue editing them!

4.3. Use the Forms


Now use your forms to work on the data:
to add another member of staff to the team
to book the car for the new person to use next week
to claim reimbursement for the petrol you bought recently
Invent some plausible data.
While you are working, you may notice improvements you want to make, so that
your forms are more efficient and easy to use.

4.4. More Interactive Forms


Create and test a form which shows one member of staff at a time, with their
expense claims appearing in a sub-form.
Create another form which lists all the members of staff, one below the other
(hint: use a Tabular Layout and change the Default View of the form to be
Continuous)

4.5. Protect Against Accidental Data Editing


Create a form for entering staff data, with a subform showing their expense
claims (you may have done this in the previous part).

IT Learning Centre 4
Databases: Practice activities

Lock and disable the text boxes for the Given Name and Family Name, so that
these values cannot be edited accidentally.
Provide a button beside each locked text box, which displays a small form that
pops up so the user can edit the value if they decide this really is necessary.

4.6. Build Queries


Create a query that shows all the times Douglas has used the car.
Create a query that shows all of Manuel’s expenses.
Create a query that finds any expense claims where the date of the claim has not
been entered. Include the person’s phone number in the query output, so you can
contact them to check the details.
Think of some more interesting queries to run on this data.

4.7. Build Reports


Create a report that lists all the occasions when the car has been booked/used,
sorted in date order and in time order within each day.
Create another report listing all of the car bookings, each time giving the name of
the person who used it and the mileage they covered.
Create a report that lists all the expenses claims, in date order.
Create another report giving the expenses claimed, this time grouping by member
of staff and including the total claimed by each person as well as a grand total.

4.8. Sample Solution


I n t Ex _ S t a ff C ar s _ 0 3. ac c db and I nt E x _ St a ff Ca rs _ 0 4. ac c d b

5 IT Learning Centre
Databases: Practice activities

5 Exercise: Meeting Rooms


- Collect Data From Filing Cards
5.1. Scenario
For some years, the receptionist has kept an eye on bookings for the various
meeting rooms in her Department, using a box of filing cards.
Because some additional meeting rooms are now being equipped, she would like
to manage the bookings using an Access database.
A blank card from the filing box looks like this:

Departmental meeting Room Booking Card


Please return the completed card to Reception

Date: Room:

From (time): Until (time):

Will you require refreshments?


Hot drinks: _____________________________
Light meal: _____________________________

Name of staff requesting:

Contact tel num (internal):

5.2. Review the data


Look at the cards shown on the next pages, to see the way the Receptionist has
been using them. Look out for extra information that people have written on
some cards, for ideas of additional fields which should be included in the
improved database design.

5.3. Design and Build


Design a database to manage this information.
Build the tables, fields, and properties using Access.
Set up relationships between the tables, using suitable fields.
Build some forms. Think about the data entry properties that would make the
forms easy and safe to use.

5.4. Enter Some Sample Data


Enter data from the cards, for a few sample records into each of your tables. Do
this early testing in Table Datasheet View.

IT Learning Centre 6
Databases: Practice activities

5.5. Meeting Room Booking System - 6 Sample Data Cards


Departmental Meeting Room Booking Card
Please return the completed card to Reception
Date: 3/4/10 Room: Cromwell
From (time): 10am Until (time): noon

Will you require refreshments? yes please ________________________


Hot drinks: no thanks _________________________
Light meal: can you make sure there is a video
projector in the room?
Name of staff requesting: Alan Pilkington
Contact tel num (internal): 284685

Departmental Meeting Room Booking Card


Please return the completed card to Reception
Date: 23/5/10 Room: Cromwell
From (time): 1400 Until (time): 1600
Will you require refreshments?
Hot drinks:  ________________________________
Light meal: not sure yet ______________________
Name of staff requesting: Michelle Patterson
Contact tel num (internal): 282348

Departmental Meeting Room Booking Card


Please return the completed card to Reception
Date: 23/5/10 Room: Patten
From (time): half past 3 Until (time): 5

Will you require refreshments?


 ________________________________
Hot drinks:
 ________________________________
Light meal:
and a projector again please
Name of staff requesting: Alan Pilkington
Contact tel num (internal): 284685

7 IT Learning Centre
Databases: Practice activities

Departmental Meeting Room Booking Card


Please return the completed card to Reception
Date: 27 and 28th June 2010 Room: Jenkins
From (time): all day Until (time):
Will you require refreshments?
Hot drinks: yes ______________________________
Light meal: _________________________________
Name of staff requesting: Doug Wilkinson
Contact tel num (internal): (2)06083

Departmental Meeting Room Booking Card


Please return the completed card to Reception
Room: Wellesley if there is level access
Date: 30/7/2010 for my colleague who doesn’t do stairs -
can you check please?
Until (time): 11 but let me know if you
From (time): 9am
need us to finish sooner
Will you require refreshments?
Hot drinks: no _______________________________
Light meal: no _______________________________
Name of staff requesting: Alice S
Contact tel num (internal): 257981

Departmental Meeting Room Booking Card


Please return the completed card to Reception
Room: Wellesley - or whichever room is
Date: 24/12/2010
big enough to seat 15
From (time): 3 Until (time): 5:15
Will you require refreshments?
Hot drinks: for 15 people _____________________
Light meal: for 10 people, 2 vege, 1 gluten-free __
Name of staff requesting: Michelle again
Contact tel num (internal):

5.6. Sample Solutions


I n t Ex _ M ee ti n gR o o ms 01 . ac c d b and
I n t Ex _ M ee ti n gR o o ms 02 F ew R ec or ds .a c c d b

IT Learning Centre 8
Databases: Practice activities

6 Exercise: Meeting Rooms


- Import and Re-organise Data From a Flat File
6.1. Scenario
For a short while, the room booking requests were managed in a flat spreadsheet
file, using Excel. You are asked to bring all this old data into your new database,
without re-typing it.

6.2. Review the Data


Look at M e eti n gR o o m Bo ok i ngs .x l s x . This data is of the same form as your
database, but it is arranged differently. Identify which columns in the spreadsheet
correspond to the fields in your Access tables.
There is some data redundancy in the flat file, so you will have some work to do in
collecting and relating the data in the Access database.

6.3. Import the Data


Import the whole of the spreadsheet data and create a new separate table inside
the Meeting Room database.

6.4. Retrieve the Staff Details


The names and phone numbers of the staff are given in the imported data, but
some are mentioned several times.
Create a query which collects the information relating to staff members (names
and phone numbers). Use Totals to group together all records for the same
person, so that each person is shown just once.
Use this query to append the staff member data to the table you built earlier for
staff. Check that each field of imported data is sent to the appropriate field in the
existing table.
After running the query, save it as a record of what you have done.

6.5. Retrieve the Room Booking Details


The dates and arrangements for the room bookings are given in the imported
data, but the staff and the rooms are given by name - an Access database requires
ID numbers (or similar) for the primary keys of the Staff and Room tables.
Create a select query which collects fields relating to the bookings (dates and
times, catering and similar requirements) from the imported table.
In the query, join the table of staff members to the imported table using Family
Name, and display the Staff ID primary key number. Also join the table of rooms
to the imported table using Room Name, and display the Room ID primary key
number.
Use this query to append the booking data to the table you build earlier for
bookings. Check that each imported field is associated with the appropriate field
in the existing table.

6.6. Housekeeping
After running the query, save it as a record of what you have done. You would
probably archive (or even delete) the imported data as it will not be needed again
in the Access database.

9 IT Learning Centre
Databases: Practice activities

Take care not to run the append queries multiple times, as you would be
appending repeat sets of imported data onto the working tables. You can safely
examine an action query by right-clicking the query name then choosing Design
View.

6.7. Sample Solution


Look at I nt Ex _ M e eti n gR o o ms 03 I mp or te d Da t a. ac c d b for one possible way of
managing this process.

IT Learning Centre 10
Databases: Practice activities

7 Further information
7.1. Getting extra help
7.1.1. Clinics
The IT Learning Centre offers bookable clinics where you can get pre- or post-
course advice.
7.1.2. About Lynda.com
Lynda.com is free to all members of the University. Visit
courses.it.ox.ac.uk/lynda and sign in with your Single Sign-On (SSO) credentials.
Some courses recommend pre- and/or post-course playlists of Lynda.com videos
to support your learning. You can watch these anywhere, anytime, and even
download them on to a tablet or smartphone for off-line viewing.
If you need a quiet place to work through playlists away from distractions, the
IT Learning Centre offers frequent Lynda Labs that you can book onto.
7.1.3. About the ITLC Portfolio online
Many of the resources used in the IT Learning Centre courses and workshops are
made available as Open Educational Resources (OER) via our Portfolio website at
http://portfolio.it.ox.ac.uk.

7.2. About the IT Learning Centre


The IT Learning Centre delivers over 100 IT-related classroom-based courses,
and gives you access to thousands of on-line course through Lynda.com.
Our team of teachers have backgrounds in academia, research, business and
education and are supported by other experts from around the University and
beyond.
Our courses are open to all members of the University at a small charge. Where
resources allow, we can deliver closed courses to departments and colleges, which
can be more cost effective than signing up individually. We can also customize
courses to suit your needs.
Our fully-equipped suite of seven teaching and training rooms are available for
hire for your own events and courses.
For more information, contact us at courses@it.ox.ac.uk

7.3. About Academic IT Services


The IT Learning Centre is part of Academic IT Services (AcIT). AcIT engages with
the University in all aspects of the use of IT for teaching, learning and outreach,
including the development of the University’s Virtual Learning Environment
(WebLearn), research data management advice, technology enhanced learning,
and digital media services including the Replay lecture capture service. If you
think AcIT can help you, contact us at academicit@it.ox.ac.uk

11 IT Learning Centre

Das könnte Ihnen auch gefallen