DATABASES
i. What is a database?
H
The software which manages the database file, such as MS Access is called
a Database Management System (DBMS). It is important to note that a
database is a file, as a document or a spreadsheet whilst a DBMS is a
software like Microsoft Word, Microsoft Excel and so on.
The DBMS software is designed so that people can keep records relatively
easily on computer. Users can add, modify or retrieve data using search
conditions and create relevant reports with ease.
Ms M. Cristina Page 1
Computer Studies Notes
your database i.e. you have to establish the fields needed. Following this
task you can create a table to contain your data.
2. Datasheet View
- Used by the person entering data into a
database
A table holds data about a particular item. The following print screen is an
example of a students table:
Ms M. Cristina Page 2
Computer Studies Notes
This form shows, and lets you manipulate data about a single recording, in
our case a single student. Such data is called a record. A record is the
basic unit of data stored in a data file. It is a collection of item, all relating
to the individual or object. Records are treated as a unit for processing.
Field Field
Name Contents
As you can notice forms represent data in a convenient form for browsing
and updating. Each form is a view of some data, together with facilities to
navigate the data, add, edit and delete records, etc.
Ms M. Cristina Page 3
Computer Studies Notes
You can move from record to record using navigation buttons provided at the
bottom of the form:
Move to the previous record in the Move to the next record in the
record set record set
Move to the first record in the Move to the last record in the
record set record set
Note that Student ID field changes as you move from record to record.
The Student ID is a number identifying a record, since no two students will
have the same student ID. It is the key field of our student collection.
Updating a Record
You can update the contents of a field within a record by clicking on the
field contents and typing in the new data.
As you move forward past the last record in the record set, you will arrive
at a blank record ready for you to fill in.
Ms M. Cristina Page 4
Computer Studies Notes
Note: the Student ID field (which is the key field of the record) appears as
Autonumber on the new record. This is because this field is not directly
editable. Instead the designer of the database has chosen to let MS Access
assign a unique ID number to each record.
5. Create a key field by clicking on the selector, the small box at the
beginning of the row for that field.
6. Click the Set Primary key button.
The key symbol is displayed to represent the key field from the whole list:
Ms M. Cristina Page 5
Computer Studies Notes
7. When you finish, click on the save button. Enter a name for the table
and select OK. If you did not select a key field, Access prompt you
about creating a Primary Key. Click the Yes button to have Access
create an AutoNumber field and make it primary key, or No to avoid
creating a primary key.
Access has 10 types of fields to store specific types of data. These include
the following:
Ms M. Cristina Page 6
Computer Studies Notes
You can set the Field Size property to specify how many characters a text
field can contain or the range of numbers that a Number field can contain.
For example, if you know that a Text field is going to contain first names,
you may want to set its Field Size property to 15. You are unlikely to
encounter a first name of more than 15 characters.
Inserting Fields
Deleting Fields
Moving Fields
Ms M. Cristina Page 7
Computer Studies Notes
So far you have been working in the Table’s Design View. You cannot enter
the actual data in this view.
1. Click the save button
2. Type a name for the table
3. Click the Ok button
4. Click the Datasheet view button
5. Type the data in the appropriate cells
6. Press the TAB key to move from one cell to the next.
Editing Records
When you are editing a record, Access displays a pencil icon in the left-most
column of the datasheet. When you move to another record making changes
to the existing record, Access saves the edited record.
Deleting Records
Ms M. Cristina Page 8
Computer Studies Notes
Apart from specifying types in the Table Design View you can also set field
sizes, input masks, formats and indexes. Formats and input masks affect
the way data appears in a table in Datasheet. However, they serve very
different purposes.
Field Sizes
Ideally you should set each field size to contain a specific amount of
characters or numbers. You should generally use the smallest possible Field
Size setting because smaller data sizes can be processed faster and require
less memory. The field size sets the maximum size of data that can be
stored in a field.
Note that:
If you change the Field Size settings for a text
field from 255 to 50, data over 50 characters will be lost
Format Property
The format property setting affects the data in the field once it is entered.
It changes how the data displays and can make it easier to read. For
example:
If you apply the Long Date format to a
Date/Time field, a date of 11,24,94 displays as “Thursday,
November 24, 1994”.
Ms M. Cristina Page 9
Computer Studies Notes
Here we are principally interested in validation checks, which the DBMS can
automatically perform on data entered into a field. The following are some
such common checks:
Type Checking
The DBMS can check that data entered into a field is of the
correct type. For example, only numbers are allowed in a numeric
field, and dates in a date field are checked to ensure that they
are valid (example: 30th February is not allowed)
Range Checking
The DBMS can check that the value entered in a field is within a
certain range otherwise it will be rejected. The range must of
course be specified by the designer of the database, since the
DBMS has no knowledge of what range is considered acceptable
in a particular application. Thus, if we have an age field in our
database, this field may be specified to accept values between 11
and 16, sp the DBMS will reject numbers outside this range.
Ms M. Cristina Page 10
Computer Studies Notes
Set Checking
The DBMS can check that the user only enters value from a
predetermined list of acceptable values, for example in a banking
database application: the account type may have to be one of
Current, Savings or Fixed. Having the user select the value from
a drop-down list can enforce this.
Indexing a Field
Option: To do this:
Ms M. Cristina Page 11
Computer Studies Notes
Searching Data
5. In the Find What section type the data you are looking for.
6. In the look In section ensure that the correct field is
displayed
7. Click on the Find next button
Sorting Data
Ms M. Cristina Page 12
Computer Studies Notes
Serial Access
Items are read, one at a time
from the physical start of file, in the order
which they are stored.
Items may vary in length, provided there is
some marker to signal the end of one item and the start of the
next.
Usually data records are placed on a file in a
particular order (e.g. alphabetical) according to a sort key. This
is known as a sequential file.
Direct Access
Items can be retrieved immediately provided
its position in the file is known.
Items must have a known length,
so that software can calculate where in the file
the required item is located.
Ms M. Cristina Page 13
Computer Studies Notes
xiii. Queries
Ms M. Cristina Page 14
Computer Studies Notes
For example, the following query result shows only those records of
students who live at Birkirkara:
Creating a query
A query cannot be created unless a database file with an existing table has
been created.
The Design View will be used to create a query. Design View shows the
table and fields on which the query is based, and the criteria to be used to
select the required data from those tables, as well as any sorting to be
performed on the data. The query design screen is really a simple tool for
creating queries – the queries itself is actually a small program written in a
specialized language called SQL (Structured Query Language).
Access creates a new query object and the query design window. This
window is divided into 2 areas:
Ms M. Cristina Page 15
Computer Studies Notes
1. Table
Field Pane
List
2. QBE
grid
Table Pane
Includes boxes for the table/s you have added to your query. These boxes
contain a field list, which is a list of the available fields in each table.
5. From the field list, double click on the fields you want to use. The
order in which you select your fields is the order in which they
appear in the dynaset (a datasheet containing the results of a
query).
6. Click the drop-down arrow in the Sort box and select the sorting
order for the data in that field.
Criteria Expressions
Ms M. Cristina Page 16
Computer Studies Notes
Criteria expressions are short statements that tell Access what subset of
your data you want to see.
Symbol Description
= Equal to
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
<> Not equal to
Examples:
Running the above query displays all students who live at Birkirkara.
Ms M. Cristina Page 17
Computer Studies Notes
Running the above query displays all students who live at Birkirkara and have
a Student ID which is greater than 5.
xiii. Forms
4. Select the layout from your form and click on the Next button
5. Select the style for your form and click on the Next button
6. Give a title to your form and click on Finish button
Ms M. Cristina Page 18
Computer Studies Notes
xiii. Reports
Once you have created your table and entered the records, you might want
to extract and print specific information from your database. For example
you might want to print students’ progress reports or generate mailing labels
for students living in a particular village.
The process of selecting and printing information is done through reports.
Report is one of the Microsoft Access database objects that presents
information formatted and organized according to your specifications.
With a wizard, you can quickly create a basic report that shows all the fields
and records in a table or query, or you can create a custom report that
displays data from selected fields in a particular format such as mailing
labels.
A grouping level is a field upon which the records are grouped. Access
determines the unique values in the field, and any records that have the
same value in that field are displayed together in the report.
In the following example, the generated report is grouped by the class field.
Ms M. Cristina Page 19
Computer Studies Notes
Ms M. Cristina Page 20
Computer Studies Notes
Ms M. Cristina Page 21