Fields and Records - ITrackLS Learning Styles

advertisement
Database
Microsoft Access10
DATABASES
Using Microsoft Access
Name :-______________________________________________Class:-______________
One of the most common uses of microcomputers is in providing DATABASES.
What is a Database?
The term database means a
large collection of data. The
data is structured in such a
way that it can be accessed
and updated easily and quickly.
The structure of a database consists of fields and records.
Each item in a record is known as a field. The details about one person or object are known as a
record. All the records, when collected together and stored are known as a file.
The database file is saved on the Hard disk.
Test yourself: Write down a description for each item
database ___________________________________________________
record _____________________________________________________
field
______________________________________________________
file
_______________________________________________________
Computer databases have many advantages over manual databases.
Manual databases include data like telephone directories and pupil records.
Fields and Records
Surname: _____________________
Forename: _____________________
A FIELD holds data/information and is made up of the Fieldname and Contents.
The above words make up 2 fieldnames with a space for the contents of each.
The FIELDNAME describes the contents of a FIELD. The FIELDs above would contain the Surname
and Forename of individuals – e.g.
Names like Smith, Jones, Reid, Brown, Cheung
Would be entered in the field with the fieldname __________________
First names like Andrew, Charlie, Maureen, Sean, Nikki
would be entered in the field with fieldname _____________________
As in the Phone Book surnames have to be kept separate from first names and so different fields are
needed for each. This is because the surnames are usually your first point of reference – it is the
surname of a person you look up first.
Once you have found the surname you will get more information – the first name, address, and
telephone number.
All the fields relating to one entry make up what is called a RECORD
e.g. The following might be the record of John Brown
Surname
Forename
Address
Town
Phone No
Brown
John
27 Albert Street
Dundee
01382 401014
106740527
1
12/02/16
Database
Microsoft Access10
Follow these instructions carefully.
Read each stage and complete each task.
Activity 1
Getting Started : Open a database file
1
Switch on
2
Log on using your network identity and password
3
Start menu
4
Programs
5
Microsoft Office - Microsoft Office Access
6
Click More…
7
Click on Vehicles and click OK
(If Vehicles doesn't appear on the list, you will get it by going to My Documents )
Note: You will have to copy
the file vehicles.mdb to your
My Documents
S1on Grove\Computing\DB\vehicles
Display of Records
Note: If certain content has been
disabled  click Options
Next to security warning and
click Enable
To View the file :
Double click vehicles
The vehicles Table is now displayed in Datasheet View
Ex 1a
Find the Forename & Surname of the person in Record 1
Find the Forename & Surname of the person in Record 4
Write the names of 2 other Fields that appear in every record
Write the contents of these 2 other Fields in Record 1
Write the contents of these 2 other Fields in Record 4
To View as a Form:
1. Close the Table displayed in Datasheet View
2. Click Tables then click Forms
3. Double click vehicles
106740527
2
12/02/16
Database
Microsoft Access10
You will see
You can move up and down the records by clicking the buttons
up 1 record
down to first record
down 1 record
up to first blank record
up to last record
Ex 1b
Find the car-make in the First & Last Record
Write the name of each Field that appears in every record :
Field 1____________________________
Field 2____________________________
Field 3 ___________________________
Field 4____________________________
Field 5____________________________
Field 6____________________________
Field 7____________________________
Field 8____________________________
Field 9____________________________
Field 10____________________________
Field 11____________________________
Field 12____________________________
Field 13____________________________
Field 14____________________________
Field 15____________________________
Field 16____________________________
Field 17____________________________
Write the contents of each Field that appears in a selected record : Record number _____
Field 1____________________________
Field 2____________________________
Field 3 ___________________________
Field 4____________________________
Field 5____________________________
Field 6____________________________
Field 7____________________________
Field 8____________________________
Field 9____________________________
Field 10____________________________
Field 11____________________________
Field 12____________________________
Field 13____________________________
Field 14____________________________
Field 15____________________________
Field 16____________________________
Field 17____________________________
106740527
3
12/02/16
Database
Microsoft Access10
Activity 2 Open the Database file - Vehicles. View as Datasheet
Find out the name of the person who is at Record No 8 ___________________________
Find out the name of the person who is at Record No 23 ___________________________
Find out the name of the person who is at Record No 48 ___________________________
Which fieldnames did you use ? ______________________________________________
View as a Form
Find out the name of the person who is at Record No 19 ___________________________
Find out the name of the person who is at Record No 37 ___________________________
Find out the name of the person who is at Record No 53 ___________________________
Which fieldnames did you use ? ______________________________________________
View as a Report
Report 2
1. Close the Form displayed in Form View
2. Click Forms then click Reports
3. Double click Car owners, make and town
Report 2 will be displayed as above
You can modify a report to display only selected records and/or the records sorted on a particular field.
(This will be covered in a later lesson)
106740527
4
12/02/16
Database
Microsoft Access10
Activity 3a
Editing a file
Editing a database can involve ADDING new records, CHANGING existing records or
DELETING unwanted records.
Adding Records
Enter details into the blank record below. (ID will be entered automatically)
FORENAME:________________
SURNAME:_______________
ADDRESS:________________________
TOWN:______________
POSTCODE:________________
SEX:___
DOB:DAY:___ MONTH:___
YEAR:___
AGE:___
CAR-MAKE:_____________
MODEL :_____________
COLOUR:______________
REG-NO:_________
COUNTRY:____________
YEAR-MAN:__________
Make sure the database is being viewed as a Form
Use
to get to the end of the database.
Enter the data for each field into the database.
Form View
Changing Data
Data can be changed in any field by entering the new data.
Jack Fleming has sold his car to a collector and bought a new one.
Change his record to include the following details :
CAR-MAKE: Renault
MODEL: Clio
COLOUR: White
Deleting Data
REG-NO: W323JPR
COUNTRY: France
YEAR-MAN: 00
Any record can be deleted from the file
You must be in Datasheet View (click Tables, double click vehicles).
Select record to delete (put your cursor in the record you want to delete).
On Home tab click Delete button
Click Delete Record
Close the database file.
Activity 3b
Test
Editing a file - Adding records
Open the Table  Telephone
Enter details for three new records below: (In Data Sheet or Form View)
Surname
Forename
Town
Phone-no
Surname
Forename
Town
Phone-no
Surname
Forename
Town
Phone-no
Add the three new records to the file
Save the table as Telephone1
Close the database file.
106740527
5
12/02/16
Database
Activity 4
Microsoft Access10
Searching the Database
You do not usually know which record you want, and it would take a long time to look through all the
records, so the program has a facility to Search for or Query the required data.
Suppose you want to view all the Smiths.
1 Click Tables, double click vehicles
2 Click Create tab
click Query Design
click vehicles in the dialogue box
click the Add button
3 Click the Close button in the Show Table dialogue box.
Query Design
window is displayed
4 Double click Forename in the vehicles field list.
This field is now shown in the design grid.
5 Double-click on Surname and Car-make. Each of the selected fields is now included in the query.
6 To Display the query as a datasheet - Click View 
7 To return to Design View – click View 
8 Under the
Surname field - Add Smith to the Criteria row
9 To Display the query as a datasheet - Click View 
Answer – write down each FORENAME and CAR-MAKE
FORENAME __________ CAR-MAKE ____________
FORENAME __________ CAR-MAKE ____________
FORENAME __________ CAR-MAKE ____________
FORENAME __________ CAR-MAKE ____________
When you want to search for specific criteria in a field: eg. Colour = green,
enter the criteria (green) in the correct row below the field name (Colour).
You can then apply the query (search) by clicking the View button 
You can also use ‘< less than’ and ‘> greater than’ in your criteria.
For example, age greater than 20, type in criteria row (under age field) >20
106740527
6
12/02/16
Database
Microsoft Access10
Complete the blanks in the following boxes, set up the Query & View Sheet:
1
Use a Query to find out the number of blue cars.
Field name
Comparison
Compare to
Colour
is equal to
__________
Answer _____________________
2
Use a Query to find out the number of green cars
Field name
Comparison
Compare to
Colour
__________
__________
Answer _____________________
3
Use a Query to find out the number of car owners who live in Dundee
Field name
Comparison
Compare to
Town
__________
__________
Answer _____________________
4
Use a Query to find out the number of car owners who live in Perth
Field name
Comparison
Compare to
_________
__________
__________
Answer _____________________
5
Use a Query to find out how many drivers are over 60
Field name
Comparison
Compare to
_________
__________
__________
Answer _____________________
6
Use a Query to find out how many cars are over 15 years old
Field name
Comparison
Compare to
_________
__________
__________
Answer _____________________
You can combine conditions with and/or in a Query, eg. find out who has a blue Ford
i.e Colour = blue and Car-make = Ford
Find out who has a blue or black car,
Find out who has a blue car or a Ford
i.e Colour = blue or Colour = black
i.e Colour = blue or Car-make = Ford
106740527
7
12/02/16
Database
Microsoft Access10
Activity 5 Combining Conditions
Complete the blanks in the following boxes, set up the Query & View Sheet (for answer):
1
Use a Query to find out who has a green Datsun
Box
Query
Field name
Comparison
Compare to
Colour
is equal to
green
Car-Make
is equal to
____________
Answer ______________________________
2
Use a Query to find out who has a red Fiat
Field name
Comparison
Compare to
COLOUR
is equal to
____________
CAR-MAKE
is equal to
____________
Answer ______________________________
3
Use a Query to find out who has a white Ford
Field name
Comparison
Compare to
COLOUR
is equal to
____________
CAR-MAKE
is equal to
____________
Answer ______________________________
4
Use a Query to find out who has a Ford and lives in Dundee
Field name
Comparison
Compare to
CAR-MAKE
is equal to
____________
TOWN
is equal to
____________
Answer ______________________________
5
Use a Query to find out who owns a Vauxhall Cavalier
Field name
Comparison
Compare to
__________
is equal to
____________
__________
is equal to
____________
Answer ______________________________
106740527
8
12/02/16
Database
6
Microsoft Access10
Use a Query to find out how many owners have a silver or gold car
Field name
Comparison
Compare to
COLOUR
is equal to
silver
COLOUR
is equal to
____________
Answer ______________________________
7
Use a Query to find out who has a surname Allen or Allan
Field name
Comparison
Compare to
SURNAME
is equal to
____________
SURNAME
is equal to
____________
Answer ______________________________
8
Use a Query to find out how many car owners live in Brechin or Forfar
Field name
Comparison
Compare to
TOWN
is equal to
____________
__________
is equal to
____________
Answer ______________________________
9
Use a Query to find out how many car owners are under 18 or over 70 years of age
Field name
Comparison
Compare to
__________
is less than
____________
__________
__________
____________
Answer ______________________________
10
Use a Query to find out how many car owners have a Ford and live in Dundee or Perth
Field name
Comparison
Compare to
__________
is equal to
____________
__________
is equal to
____________
__________
is equal to
____________
Answer ______________________________
106740527
9
12/02/16
Database
Activity 6
Microsoft Access10
Creating a New Database
In a Microsoft Access database the main object is a Table. This is the first object created.
We are going to create a new table for Telephone numbers showing the following information:
Note: the only way Access
will accept a leading 0 (zero)
as in a telephone number is
by using Text as the Data Type.
1 Click Create tab
2
Click Table Design
A blank table is displayed in Design view
3 Type Surname into the Field Name box on the first row then press [TAB].
4 Select Text from the Data Type drop-down list
5 In the Field Properties section, set Field Size at 35 
Add the following fields to the Telephone table:
Field Name
Forename
Data Type
Text
Field Size
30
Field Name
Town
Data Type
Text
Field Size
16
Field Name
Telephone
Data Type
Text
Field Size
10
Click the View command
Tele1.
choosing Yes when prompted to save the changes – name the table
You are now ready to Add records to the Table.
Data can be added by clicking in the Field column and typing your data.
You can move to the next field by pressing the Tab key.
When you have finished adding data (records) – close the Datasheet window and the Table will be
saved automatically.
Click here 
106740527
10
12/02/16
Database
Microsoft Access10
Entering data
Make up 10 records and enter them into your new database. The data does not have to be
true - but it should not be silly nor offensive.
Remember :You can enter the data when you View the database in Datasheet View.
If you can't think of suitable records, enter the following:
Angus Perry 14 Smith St Dundee 01832 010102
Freddie Laker 42 Station Rd Dundee 01382 010345
Beattie Brown Dundee 01382 122128
Gerry Fisher Dundee 01382 123400
Charlie Davidson Arbroath 01241 7742456
Hazel Bowtree Dundee 01382 023456
Deborah Marshall Arbroath 01241 7703786
Ira Howe Dundee 01382 023459
Eddie Carlsen Arbroath 01241 37896
Jessie McKenzie Carnoustie 0124112345
Activity 7
Test
Creating your own database.
Create a database file to hold information about a video collection. The information should include the
name of the film, the type of film such as comedy, thriller, etc., the length of the film and the film
classification such as 15, PG, etc.
Decide on suitable fieldnames, data types and field widths and enter them below :
Fieldname 1 ____________________ data type ______ field width ________
Fieldname 2 ____________________ data type ______ field width ________
Fieldname 3 ____________________ data type ______ field width ________
Fieldname 4 ____________________ data type ______ field width ________
Create the database using these fieldnames, data types and field widths.
Make up 6 records and enter them below :
record 1 ____________________________________________
record 2 ____________________________________________
record 3 ____________________________________________
record 4 ____________________________________________
record 5 ____________________________________________
record 6 ____________________________________________
Add the records to your database and Save your file.
106740527
11
Filename _____________
12/02/16
Database
Activity 8
Microsoft Access10
Creating a simple Report
We are going to create a new report about driver’s name, age and colour of car.
The information should be displayed like the following:
Age and colour preference
Forename
-----------
Surname
---------
Age
-------
Colour
-------
To create the report:
1 Click Create tab
2 Click Report Wizard
3 Select Table: vehicles from the drop-down list.
4 Select each field  Forename, Surname, Address
and Town by clicking the select button
5 Click Next > button
6 You are asked if you want any grouping - Click Next > button
7 You are asked what sort order you want for your records.
Select Surname from the drop down list (Ascending)
Click Next > button
8 You are asked what layout you want for
your report.
Choose Layout Tabular, Orientation Portrait
Click Next > button
9 You are asked what style you would like
Choose Flow
Click Next > button
10 You are asked what style you would like
Type – Age and colour preference
Click Finish button
The wizard will generate your report then display it in a preview window.
106740527
12
12/02/16
Database
Microsoft Access10
Activity 9
Test
Creating a Report
Create a new report called Insurance. The Insurance report will contain the driver’s name, age,
postcode and model of car. The Title of the report will be Car Insurance Details and the information
should be displayed like the following:
Car Insurance Details
Forename
-----------
Surname
---------
Age
-----
Postcode
-------
Model
---------
The contents of the Age field should be Centre aligned.
Check your report using the Preview option.
The insurance company would like the report sorted by age and within each age group by surname.
They only want to include drivers aged 25 or under in this report.
Enter the Sort & Query details below:
Sort details (both ascending) :Fieldname 1 ____________
Fieldname 2 ____________
Query details :Field name
Comparison
Compare to
_________
__________
__________
Modify the report to include the Sort & Query details
i.e. Select report, click Modify, click Sort tab & enter details, click Query tab & enter details.
Print out your report and attach it below:
Modify the report to include only those drivers who live in the DD2 area.
Print out your report and attach it below:
106740527
13
12/02/16
Database
Microsoft Access10
Database Project
1
Worksheet 1
Copy the following details onto a card and fill in the information about yourself
Pupilfile Database
Surname ________________
Sex (M or F) __
Name(s) ______________
Register Class _______
Date of Birth (use numbers only)
Day_____ Month _____ Year _____
Address _______________________________________
Phone ________________
Tasks 2 - 5 will be carried out as a group activity. Each group will have its own code. One person in the
group should time each activity.
Give your completed card to a group member who will collect them together to create a group database.
2
3
Use these cards to find out:
(a)
Who is the oldest?
_________________________ Time taken _______
(b)
How many girls are there? ______________
Time taken _______
Put your database in alphabetical order of SURNAME and then first NAMES, with boys and girls
in the same list. We can say that this database is sorted into alphabetical order.
How long did it take you? ____________________
4
Now sort your database in order of age, with the youngest first.
How long did it take you? ____________________
5
Now answer these more complicated questions and note the time taken for each.
Who was born in Spring? ______________________________ Time taken _______
Who has the same name? ______________________________ Time taken _______
How many boys have Birthdays in December? ______________ Time taken _______
If the databases from all groups were put together, a much larger database could be created.
This is much harder to handle and will obviously take longer.
6
Try answering some of the above questions again with the cards for the whole class.
Remember to get one pupil to time each activity.
What problems might you have using a large database?
106740527
14
12/02/16
Database
Microsoft Access10
Database Project
Worksheet II
You are now going to create a computer database for your own group using the Microsoft Works
software package.
Your database should be CREATED with 9 fields as follows (the widths will automatically be set to 10
and you can adjust by dragging out or in to suit) :Fieldname
Field 1
Field 2
Field 3
Field 4
Field 5
Field 6
Field 7
Field 8
Field 9
SURNAME
FORENAME
SEX M or F
REGCLASS
DOB:DAY
MONTH
YEAR
ADDRESS
PHONE No
Once you have created the database structure, you should add the details (records) for each person in your
group (make sure you include your practical section e.g. 1/1a in the REGCLASS field).
1
Using the computerised group database find out the answers to the following and also write down
the SEARCH CRITERIA for each question (i.e. how you got the answer) This will probably be a
QUERY or a SORT
TimeTaken
a)
Who is the oldest? _________________________________
_________
To solve this problem you would use the SORT option.
Sort by
YEAR (ascending)
Then by
MONTH (ascending)
Then by
DOB:DAY (ascending)
b)
How many girls are there? ___________
_________
To solve this problem you would use a QUERY :- SEX is equal to F
c)
Who was born in Spring? ____________________________
_________
To solve this problem use ______________________________________________
_______________________________________________
d)
Who has the same forename as yourself? ____________________
_________
To solve this problem use ______________________________________________
e)
How many boys have birthdays in December? _________
_________
To solve this problem use ______________________________________________
______________________________________________
Make sure you save your group database in your own folder
(File, Save As, and save in C drive, Classes, S1, your practical section e.g. 1a)
106740527
15
12/02/16
Database
Microsoft Access10
Database Project
Worksheet III
You are now going to solve the same problems as in Worksheet II, but this time using the whole Class
database.
Method:
Open Microsoft Works and load your group database, then add the names from the rest of
the groups to your own database. Answer the following questions and state the SEARCH CRITERIA for each
question.
1
Using the computerised class database find out:-
TimeTaken
a)
Who is the oldest? _________________________________
_________
Search Criteria - _____________________________________________________
_____________________________________________________
b)
How many girls are there? ___________
_________
Search Criteria - ______________________________________________________
c)
Who was born in Spring? ____________________________
_________
Search Criteria - ______________________________________________________
______________________________________________________
d)
Who has the same forename as yourself? ____________________
_________
Search Criteria - _____________________________________________________
e)
How many boys have birthdays in December? _________
_________
Search Criteria - ______________________________________________________
_______________________________________________
2
SORT the database into alphabetical order and PRINT out the list using a REPORT Format for
Names and addresses.
3
Which is quicker, using the manual database or the computerised database?
____________________________________________________________
4
If there was a pupilfile database for the whole school, would it be better as a manual or computer
database? Why?
____________________________________________________________
5
Suggest another way to enter the Date of Birth field. Does this have any advantages or
disadvantages when trying to answer the above questions?
___________________________________________________________________
___________________________________________________________________
106740527
16
12/02/16
Download