You are on page 1of 12

2.

3 DATABASES AHMED THAKUR

2.3 DATABASES

Data: The collection of facts and figures is called data.

OR

The raw facts and figures are called data.

OR

R
Unprocessed information is called data.

Information: The processed data is called information.

KU
Table: The collection of records and fields is called table. A table is also known as a file.

Record: Categorized information is called a record. A record is also known as a row.

Field: The category of record is called a field. Field is also known as column.

A
Key field: A field in a record structure or an attribute of a relational table that has been designated
to be part of a key. Any field can be keyed, or indexed, to improve or simplify the performance of
retrieval and/or up-date operations.
TH
Primary Key: In databases, the key field that serves as the unique identifier of a specific tuple (row)
in a rela-tion (database table).

Database: The collection of files is called a database.

A database is a way of storing information in an organised, logical way. It's important to know when
to use a database and be aware of its advantages.

Record structure
ED

Before setting up a database, the record structure must be decided to make best use of
the memory and backing store, and to make searching and report creation easier.

OR
HM

A file composed of records, each containing fields together with a set of operations for searching,
sorting, recombining, and other functions.

DBMS: A software interface between the database and the user. A database management system
handles user requests for database actions and allows for control of security and data integrity
requirements Acro-nym: DBMS. Also called database manager.

RDBMS: A database or database management system that stores information in tables-rows and
columns of data-and conducts searches by using data in specified columns of one table to find
additional data in another table. In a relational database, the rows of a table represent records
A

(collections of information about separate items) and the columns represent fields (particular
attributes of a record). In conducting searches, a relational database matches information from a
field in one table with information in a corresponding field of another table to produce a third table
that combines requested data from both tables.

File operations
File operations are the different things that can be done to a computer file. The main types of file
operation are searching, sorting, updating and merging.

 Searching

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 1
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

Searching, or interrogating a file, involves looking for an individual record or group of rec-ords
that match a certain condition.

Searches are also called queries. To search a database the user must enter a query. The query
tells the software which fields to look at in each record and what to look for.

 Sorting
Sorting involves putting the records in a file into a particular order, such as alphabetical or-der,

R
either ascending or descending.

 Merging

KU
Merging involves combining two files to produce one new file.
This can be done by merging a file of new records to be added with another file that contains
all of the existing records — called the master file.

 Updating
The information stored in computer files must be kept up-to-date or it will cause problems for the

A
business or organisation that’s using it. To keep a file up-to-date it must be regularly up-dated.
This involves inserting, deleting and amending records. When a new record needs to be added
to a file, it is inserted. Records are deleted when they are no longer needed. Records are
amended when the data in one or more of the fields needs to be altered for some reason

Database packages
TH
Most databases are set-up using a database package. A typical database package will allow a
user to:

 Create a file by entering their own field definitions.


 Specify automatic validation checks for fields.
 Add new fields to records or delete fields that are no longer needed.
 Add, edit and delete records in a file.
ED

 Perform simple searches and complex searches using more than one condition.
 Import data from other applications software;
 Export data in standard file formats to other applications software;
 Create customised report forms for output;
 Create customised data entry screens;
 Create customised menu screens and link them menu together;
HM

 Link files together using common fields.


A

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 2
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

 define a single-table database from given data storage requirements

For example, a car showroom wants to record details of the cars it sells. Before setting up the
database, the following questions need to be answered:

1. What information is needed?

R
2. What validation could there be?

With these questions answered, informed decisions can be made about the record structure. This is

KU
how it might begin:

Record structure
FIELD NAME FIELD TYPE FORMAT

Registration number Alphanumeric Up to 7 characters - the key field

A
Make Alphanumeric Up to 15 characters
Model Alphanumeric Up to 15 characters
Date first registered Date DDMMYY
Price Currency Up to 5 numbers
TH
Taxed Yes/No (Boolean) 1 character Y/N

...

When designing a database it is important to choose the correct field type. This ensures that
the data stored is usable and it makes validation easier. For example, if the price paid for goods was
stored in a text field, then the database wouldn’t be able to add each individual figure to produce
ED

a total.

Key fields
A database should always contain a key field.

The key field is a unique identifier for each record.


HM

The following are examples of key fields:


 car registration number
 National Insurance number
 your school's examination centre number
 your own examination candidate number

Storing data in tables


Databases store data in tables, a single database file can store many tables, queries and reports. In
the example table below there are six columns (divided vertically) and four rows (divided
horizontally), each column has a heading, eg Registration number.
A

REGISTRATION NUMBER MAKE MODEL DATE FIRST REGISTERED PRICE TAXED

R623 PHM Ford Fiesta 010198 6800 Y


P887 LHW Rover 200 010397 7500 Y
P812 WHJ Peugeot 406 010996 7000 N
A database in which all the data is stored in a single table is known as a flat file database.

RELATIONAL DATABASES

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 3
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

A relational database has more than one table and the tables are linked using key fields. For
example, a library database could have three tables:

1. customer - when a customer joins the library a record is created. It stores their details such as their
first name and surname and includes a unique Customer ID.

2. book - each book in the library has a record. It stores details about the book, such as the author
and title and includes a unique book ID.

R
3. lending - when a customer borrows a book, the lending table stores the customer's unique ID
and the book's unique ID in a record. The record could also include additional information such

KU
as when the book was borrowed and when it's due back.

The customer and book ID are both examples of key fields.

Advantages
 The book's details and the customer's details need only be entered into the database once.

A
 Because of this, mistakes are less likely to happen and if there were a mistake in a customer's
record, for example, correcting it will correct the mistake database-wide.
 Duplication is avoided - this keeps the database's file size down.
 Details about books and customers are easily accessible using their unique IDs.
 Queries can be performed and reports generated, eg a list of books a customer has borrowed
since joining the library.
TH
Why use a database?
 Databases can store very large numbers of records efficiently (they take up little space).
 It is very quick and easy to find information.
 It is easy to add new data and to edit or delete old data.
 Data can be searched easily, eg 'find all Ford cars'.
 Data can be sorted easily, for example into 'date first registered' order.
ED

 Data can be imported into other applications, for example a mail-merge letter to a customer
saying that an MOT test is due.
 More than one person can access the same database at the same time - multi-access.
 Security may be better than in paper files.

Database uses
HM

When a database holds details about people, it's likely to include their first name, surname and their
date of birth. In addition to this, specialist information is stored depending on the database's
intended use.
 The police have details of all known criminals in a database, e.g. crimes they've committed.
 Schools use a database to store details about their pupils, e.g. how many days they've been off
school sick.
 A hospital will store details of all its patients in a database, e.g. a history of their health issues.
 The Government uses a database to store records of people's income tax payments.
 A database is used to keep track of all the drivers in central London who have (or haven't) paid
the Congestion Charge.
A

In the case of the Congestion Charge database, if someone hasn't paid the congestion charge, a
fine will be issued. The database would play an integral part in automating the process.

Information stored in the other databases listed above could be used in similar ways.

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 4
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

 choose and specify suitable data types

Data capture
Before setting up a database the data must be collected. This can be done using a data capture
form.

R
A data capture form is designed to collect specific data.

A form completed by a customer buying a car from a showroom is an example of a data capture

KU
form.

A
TH
An example of a data capture form for a car showroom

Data capture forms often use boxes or a set amount of spaces and occasionally provide examples
too. This is to make sure each field is completed correctly.

Data is often entered as a code in a database, for example in the above data capture form Y is
used for Yes and N for No. Codes like this are used because they:
 are quicker to type in
ED

 use less disk space


 are easy to validate
 make searching the database easier as data is entered in a standard format

Data can be stored in many different formats called 'data types'.


HM

When setting up a database or spreadsheet, it is important that the correct data type is selected for
each field. This is because the data type will determine what can be done with the data held in that
field e.g. sorting, searching, calculations etc.

It also can determine the format in which data is displayed e.g. a date/time data type will allow you
to pick the format of your choice, 14/05/08, 14 May 2008, 14th May 2008 etc.

Finally, some data types are able to automatically validate the data being entered.

Again the date data type provides us with a good example. When you use a date/time data type
A

then each date will be automatically checked to ensure that it can actually exist. For example, you
would not be able to enter the date 31/02/2008 - it would automatically be rejected or return an
error message.

Most common Data Types in Databases:


1. Text
2. Number/Numeric
3. Boolean
4. Date/Time
5. Image

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 5
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

Example of Data (Field) Types in MS-ACCESS

R
KU
A
TEXT
TH
A text data type can hold any letter, number, symbol or punctuation mark. It is sometimes referred
to as 'alphanumeric' or 'string'.

The data can be pure text or a combination of text, numbers and symbols.

Examples of text data types in use:

ITEM VALUE
ED

Name Joe Bloggs


Address 101, Any Street, That Town, TR34 9RT
Telephone Number 01234 56789
Car Registration EA05 NXR
HM

Car Colour Blue

NOTE: people often assume that a telephone number would be stored as an 'integer' data type.
After all, they do look like numbers don't they! But think about it ...

Telephone numbers need to be stored as a text/string data type because they often begin with a 0
and if they were stored as an integer then the leading zero would be discounted.

The other reason is that you are never likely to want to add or multiply telephone numbers so there
A

is no reason to store it as an integer data type.

NUMBER
A number data type contains as you probably have already guessed, numbers.

Here are some examples of numerical data:


ITEM VALUE

Weight in Kg 12.25, 19.99, 199.99

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 6
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

Room measurement in metres 14.5


Temperature (degrees Celsius) 37.5

When you choose a 'number' data type you may have the option of further refining the data type
thus affecting the rules applied to it and the way it is displayed. For example:
 Integers
 Real or Floating Point

R
 Currency

Integers

KU

An integer stores whole numbers, either positive or negative. Integers however cannot store
numbers with decimal places.

 Real or floating point


Your numerical data might need to be formatted with decimal places. This means it cannot be
stored as an integer number. Instead it is known as a 'real' number. You can specify the number

A
of decimal places that you need.

 Currency
When you choose to format numerical data as currency then it will automatically be given two
decimal places. However, you can choose to format currency with no decimal point because
TH
in some circumstances it would not be appropriate to display the pence. Think of an estate
agent, they might sell a house for £295,000. It would look daft displayed as £295,000.00.

The currency data type also allows you to display the correct currency symbol such as £ or $.

BOOLEAN
Boolean data holds one of two allowed values, for example:
 yes/no
ED

 true/false
 0/1

A boolean data type is used to answer questions where there are exactly two options, three options
would mean it was no longer boolean data.
HM

Here are some examples of questions where the responses would be stored as boolean data:
 Has the heating been turned on? Yes / No
 Are you employed? Yes / No

DATE / TIME
As it says 'on the tin', a date / time data type is used to store any data that is related to date or time.

The tricky thing about date / time is that there are so many ways of showing it. And some countries
have a different way of representing a date. For example:
A

9/4/94 in the USA means 4th Sept 94


9/4/94 in the UK means 9th April 94

By using a date /time data type, you can choose the format for how you want your data to be
automatically displayed.
For example: 14/05/08, 14 May 2008, 14th May 2008 etc.

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 7
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

Another reason to use a date /time data type is that it can provide some basic validation on the
data being entered.

R
KU
A
TH
For example, you would not be able to enter the date 31/02/2008 - it would automatically be
rejected or return an error message.

Many software application avoid the complexity of date formatting by offering a pop-up date
picker like the one shown above that is part of an accounting package.

Image
Databases allow graphical images such as photographs to be stored as a data type.
ED
HM
A

Sample Employee Record with Image

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 8
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

Images are binary files rather than text or numbers which is why a specific data type is required.

Different file types such as .bmp, .jpg, .tiff can be stored.

EXAMPLE BY PAST YEAR QUESTION:


JUNE 2016, P22, Q7
A database, SOFASELECT, was set up to show the prices of suites, sofas and chairs for sale from an

R
online furniture warehouse. Part of the database is shown below.

KU
A
TH
(c) State the data type you would choose for each of the following fields.
ED

Number of Seats
Ans: number/integer

Price in $
Ans: currency/real
HM

 choose a suitable primary key for a database table

Primary key (Key Field)


A primary key is data that is unique to each record in a database or file. This prevents any records
from having the same value. The Student ID is the primary key field in the database below.

Student records
A

SURNAME FIRST NAME STUDENT ID TOWN START DATE

Stickleford Emma 961534 Dudley 01/09/2007


Johnson Mark 961535 Cosely 01/09/2006
Patel Ian 961536 Birmingham 01/09/2004
Barnston Michael 961537 Birmingham 01/09/2007

Key fields

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 9
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

A database should always contain a key field.

The key field is a unique identifier for each record.


The following are examples of key fields:
 car registration number
 National Insurance number
 your school's examination centre number
 your own examination candidate number

R
EXAMPLE BY PAST YEAR QUESTION:
JUNE 2016, P22, Q7

KU
A database, SOFASELECT, was set up to show the prices of suites, sofas and chairs for sale from an
online furniture warehouse. Part of the database is shown below.

A
TH
ED

(b) State which field you would choose for the primary key.
Ans: Brochure Number
HM

Give a reason for choosing this field.


Ans: Uniquely identifies each record/each Brochure Number different/no duplicates

 perform a query-by-example from given search criteria

AND/OR/NOT queries
Applications such as Microsoft Access use query language to narrow down search results. A query
can look at more than one field.
A

REGISTRATION NUMBER MAKE MODEL DATE FIRST REGISTERED PRICE TAXED


R623 PHM Ford Fiesta 010198 6800 Y
P887 LHW Rover 200 010397 7500 Y
X842 PLD Ford Mondeo 010196 8100 N
P812 WHJ Peugeot 406 010996 7000 N
T419 PCP Citroen C4 010999 6000 Y

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 10
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

This is a list of common terms used in query language with example usage based on the table above:
1. AND - use to find all records where the make is a Ford AND the price is less than 8000. This would
return the Fiesta but not the Mondeo.
2. OR - use to find all records where the make is a Ford OR Rover. This would only return the Ford
Fiesta, the Ford Mondeo and the Rover 200.
3. NOT - use to find all records where the make is NOT Citroen. This would return all records except
the Citroen C4.

R
In query language, the above examples would look similar to this:
1. [Make] = "Ford" AND [Price] < 8000

KU
2. [Make] = "Ford" OR [Make] = "Rover"
3. [Make] = NOT "Citroen"

EXAMPLE BY PAST YEAR QUESTION:


JUNE 2016, P22, Q7
A database, SOFASELECT, was set up to show the prices of suites, sofas and chairs for sale from an

A
online furniture warehouse. Part of the database is shown below.

TH
ED
HM

(d) The query-by-example grid below selects all the furniture in cream leather.
A

Show the output from the query-by-example.

Ans: Recliner sofa 1,200 RS23


Recliner chair 600 RC01

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 11
2210 ahmed_thakur@hotmail.com, 0300-8268885
2.3 DATABASES AHMED THAKUR

2.3 DATABASES

(e) Complete the query-by-example grid below to select and show the brochure number,
material, colour and price of all the furniture with 3 or more seats.

R
KU
Ans:

A
TH
ED
HM
A

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


Page 12
2210 ahmed_thakur@hotmail.com, 0300-8268885

You might also like