Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Databases by Fazul N.

A computerised database stores data in one or more organised tables. For example the following database table stores details of items produced by various manufacturers:

The above database table contains 4 rows (= 4 records) and 6 columns (= 6 fields which are Item, Stock code, Size (cm)...etc). Database software is designed to make it easy and efficient to store, edit, sort and search information. Key Terms: Field - a field is used to store an individual item of data. Example: typical fields might be 'surname', 'colour', 'height', 'DOB' etc. Key Field (Primary key) - a field that is unique for each record in the database and can therefore be used to identify just that record. Example: A field like 'surname' would not make a good key field because two records in a database of people could easily have the same surname. In the above table, the key field is Stock code because it is unique (never repeats in the table). Record - a record is a group of related fields. Example: In a database of doctor's patients, each patient would be a separate record, with fields for 'surname', 'DOB', 'address', 'allergies' etc.

Data Types: When a database is designed, all the fields are set to accept a particular data type. This helps check for the wrong type of data being entered and makes sure the data is stored as efficiently as possible. It also means it will be sorted correctly.

DATA TYPE Alphanumeric/ text

DESCRIPTION A field of this data type will accept both numbers and text. A field of this data type is used to store numbers. A field of this data type will only let you enter a 'Yes' or a 'No'. This may be as text (YES/NO or TRUE/FALSE) or as a tick/blank. This special field stores days, months and years so that records can be sorted correctly. Date fields can display the date information in different formats such as the full name of the day/month (28th August 1961) or the numerical versions (28/08/61). Money

Numeric Logical/Boolean

Examples of fields for use Surname, First name, Car registration number Height of player (in metres) Result

Examples of data John, Kerry, A140, X60 1.70, 1.55, 25 Pass/ Fail, Yes/ No, True/ False

Date

Date of Birth (DOB), Date of Appointment, Date of Registration

14/04/88

Currency

Cost price, Selling price

$ 40.50, MUR 20

For the example table on previous page, the field names and data types would be as follows:

Database table design

A database needs to be created to show items of equipment in a science laboratory, their cost, on what shelf they are located and the status whether more need to be ordered. Before creating a table, it needs to be designed as follows: Field Item ID Item Quantity Cost ($) Shelf Status for Order Data Type Numeric Text Numeric Currency Text Boolean Field size (field length) 3 20 3 6 1 1

This produces the following table which can be filled with records. Item ID 11 12 13 14 15 16 Item Test-tube Tripod Shelf Bunsen Burner Flask Thermometer Quantity 30 20 10 35 1 5 Cost ($) $200 $300 $350 $500 $200 $1200 Shelf A B A C D A Status for Order Y N N N Y N

State the number of A. Records: 6 records B. Fields: 6 fields in the above table

QUERIES A query is a search condition. It will allow you to find records that meet the conditions you specify.

Which records will be listed if the following query (search condition) is input? Use the last table on previous page to help you. a. Quantity > 20 Item ID 11 14 Item Test-tube Bunsen Burner Quantity 30 35 Cost ($) $200 $500 Shelf A C Status for Order Y N

The above 2 records with Item ID of 11 and 14 are displayed by query Quantity > 20. b. Quantity > 20 AND Shelf = A Item ID 11 Item Test-tube Quantity 30 Cost ($) $200 Shelf A Status for Order Y

c. Quantity > 20 OR Shelf = A

Item ID 11 13 16

Item Test-tube Shelf Thermometer

Quantity 30 10 5

Cost ($) $200 $350 $1200

Shelf A A A

Status for Order Y N N

Write down a search condition which would find all the items on shelf B which cost less than $ 40. Shelf = B AND Cost ($) < 40

You might also like