Grade 11 Chapter 9 Computer Science
Grade 11 Chapter 9 Computer Science
Grade 11 Chapter 9 Computer Science
We also use Relational Databases where two or more tables are linked together. This
through will be studied at A level or IB, for IGCSE only single-table databases are linked
together. This through will be studied at A Level or IB, but for IGCSE only single databases
are need to be studied.
1
DATABASE STRUCTURE
A database is organized using a set of key components. These include:
Entities - each record item
Attributes - details about the entity
Field - columns used to capture attributes
Record - one row of details about an entity
Table - a set of fields and records
Primary key - unique number for an entity
This is another example table of a flat-file( single table) database. The entities are students
and the attributes are details about the students.
For example, validation checks that a postcode has been entered in the correct
format( depending on the country, the right combination of letters and number) and
verification checks the postcode being entered is the correct database.
ACTIVITY:
State what field would you expect to find
in each record for the doctor’s
appointment and given field a suitable
name.
2
DATA TYPES AND PRIMARY KEYS
THE BASIC TYPES OF DATA
There are 6 basic data types that can be assigned to a database.
Here is an example of a database table with rows and columns with different data types in
each.
PRIMARY KEY
Here is an example of a database tables with rows and columns with different data types in
each.
Each record
within a table
contains data
about a person,
a single item, or an event, and it is important to be able to uniquely identify
it, especially when you have a very large database and you need to find
something quick, e.g a car parts database.
For this reason we add another field to the database that uniquely identifies
the item in the row. This field is called primary key. This field must contain data values
that are never repeated in the table, e.g. a unique ID Number.
3
KEY DATABASE TERMS;
Data - information within database
Table - a structure in which data is stored
Flat - file database- a single table database
Record - a collection of data about a single item
Field - one piece of data
Primary key - a unique identifier for each record
Index - a list of values or items
Query - a method of searching a database
Range - start/ End
Presence - checks if the data is entered in a specific filed or not
Validation - this is checking that the correct type of data is entered
Verification - this checks that the data is actually the data you want
For example, somebody needing to visit a patient would only require word number and the
bed number of the patient in order to find where they are in the hospital. Whereas a
consultant need a list of the names of all patients that they care of.
QL SCRIPTS
An SQL script is a list of SQL commands that perform a given task, often stored in a file so
the script can be re-used.
WHAT IS SQL?
Databases use their own type of programming language. This language is known as
structured language, or SQL.
4
Data can be retrieved using the commands, SELECT, FROM and WHERE, for example:
5
6
EXAM STYLE QUESTION
A motorcycles manufacture offers various combinations of;
>> seat colour >> engine size >> paint colours
A tables, MyMotobike was set up as single-table data base to help customers which seat
and paint combination were possible.
Question no 1
1. State the number of record shown in the table
6
2. State the number of fields shown in the table.
9
3. State, with reason, if any of the field are suitable to use as primary key.
I would chose the CODE field because the information in each cell is unique.
Question no2
The following SQL command was used:
SELECT code
FROM MyMotobike
WHERE Sea Colour= ‘’ White’’
AND ( 50cc OR Blue)
Question 3
A customer wanted to know all possible combinations for a motorcycle with brown seats
and either black paint colour.
SELECT*
FROM MyMotobike
WHERE Seat Colour = ‘Brown’
AND( ‘ Black ‘ OR ‘ Blue ‘ )
7
8