Unit 18 - Data Types and Organization
Unit 18 - Data Types and Organization
1
Unit -18 Data types and Organization
An organized set of data is referred to as a
database. Each student has some data
associated with them. Example : Id. No,
Name, DOB etc.
What is a Record?
The set of data associated with a single
object or person.
The data in each record is different, but each
record has the same structure.
What is a Field, and What is a Field Name?
Each record contains same items.
These items are called fields.
Each field has a name.
Each field will contain different data in each of the
records.
The field is the box that you would write in
The field name is the label next to the box
The data is what you would write in the box
What is a Key Field / Primary Key?
To access a correct record in a database, it is necessary to individually identify every record. Since, each
field can have same/similar data the value can be repeated.
The table should be designed in such a way that every record has a unique field where data is not
repeated. Example : ID number.
The ID number is the ideal field to use to uniquely identify each individual record. We call this field the Key
Field, or Primary Key. 2
Unit -18 Data types and Organization
Database Viewed as a Table
A tabular view is compact and allows you to see a lot of records in one go.
The column headings correspond to the database field names...
Each cell of the table corresponds to a field, and contains an item of data...
3
Flat-File Databases Unit -18 Data types and Organization
A 'flat-file' database has only a single table of data.
It has repeated data within the fields
It wastes space in the database
It takes time to input, typing the same data over and over and can lead to typing mistakes.
It is difficult to update, as the same data need to be entered in every record.
Relational Databases:
• A 'relational' database is one that contains two or more tables of data, connected by links called relationships.
• The data is spilt and repeated data is removed from the main table, and placed in a table of its own.
• Both the tables are independent, both have their own primary key.
• Student table key field is student ID number. Class table key field is class (code)
• These two tables can be linked together using the common class field.
Data Validation:
To check whether the data is sensible, reasonable or acceptable to the data type for a
given field.
If original data is incorrect it will still be incorrect after it has been copied accurately
Validation is always carried out by the computer.
Validation helps in keeping clean, correct and useful data for processing.
It if the process of checking the data against the set of validation rules which you set up
when developing your new database
5
Data Validation:
Unit -18 Data types and Organization
1. Length Check is used to check whether the data is of exact number of characters / digits.
Example : AE021 , The centre number is only 5 characters. Not more not less.
2. Format /picture Check – is used to check whether the data is of the given format.
Example : AE021, The centre number is only 5 characters. Out of which first two letters for the
country and the next 3 digits for the centre number.
3. A range check - is used with data consists of numbers, currency or dates/times. To check whether
the data is within the range.
Example: day of the week is between 1 and 7 or also can be given as Day >=1 and <=7
4. Limit check : Only one boundary of range is known . Example: Cost of book is not less than 20 >=20
5. Type Check is used to ensure data is of the correct data type
Example : only numbers are allowed. Can not type 1oo instead of 100.\
6. Presence check to ensure that the field is not left blank. Example : password.
7. Boolean Logical data (invalid character) check : Only one of the two values are allowed. (yes/no),
(true/false) (On/Off) in Access. But in real life has only two values and you choose one value.
8. Lookup list: (choose one from more than two values )
- speeds up data entry because it is usually much faster to pick from a list than to type each individual
entry
- improved accuracy because they reduce the risk of spelling mistakes
- limit the options to choose from by only presenting the required options
9. Check digit The computer will perform a complex calculation on all of the numbers and then
compare the answer to the check digit. If both match, it means the data was entered correctly.
Example : ISBN 1 84146 201 2
6
Unit -18 Data types and Organization
(q1) The manager of a supermarket uses a database to store data about the
products she sells. This is part of the database.
(a) How many records are there in this part of the database?
(b) How many fields are there in this part of the database?
(c) The records shown are to be sorted in descending order of number in stock.
What will be the bar code of the first record in the database after it has been
sorted?
(d) Give the name of a field that contains numeric data.
(e) Identity the field type of the Producer field.
(f) Which field would be the key field? Why?
7
Unit -18 Data types and Organization
Q(2) A sports shop owner uses a database to store data about the products he
sells. This is part of the database.
(a) How many fields are there in this part of the database?
(b) How many records are there in this part of the database?
(c) Give the name of the field that is already sorted in order.
(d) The records shown are to be sorted in ascending order of number in stock.
What will be the brand name of the first record in the database after it has
been sorted?
(e) Which field would be the key field?
8
Unit -18 Data types and Organization
Q(3) A school library has a file for storing details of the books it has and a file for
storing details of its borrowers. The two files are linked using a common field.
9
Unit -18 Data types and Organization
Q(4): The manager of a bookshop uses a database to store data about the books
she sells. This is part of the database.
(a) How many fields are there in this part of the database?
(b) How many records are there in this part of the database?
(c) The records shown are to be sorted in ascending order of Number in stock.
What will be the title of the book which will be the first record in the
database after it has been sorted?
(d) What is the title of the book which has no more than 12 copies in stock and is
not Fiction?
(e) Describe a validation rule can be used on next order due field?
10
Unit -18 Data types and Organization
Q(5)An airline keeps a database of all the flights it operates. A short extract is shown below.
(a)Explain fully, what is meant by the following validation checks using the extract above.
Range check: Field: Number_of_passengers >=135 AND <=375
(b)Using the extract above, give an example of one field which would contain:
11
Q(6)The manager ofUnit -18 Data
a computer shop types and Organization
uses a database to store data about the computers
he sells. This is part of the database.
(a) Write down the number of records shown in this part of the database. 8
(b) Write down the number of fields shown in this part of the database. 5
(c) The records shown are to be sorted in ascending order of Makers_name then
ascending order of Processor_type.
Give the Processor_type of the last record in the database after it has been sorted. E3000
(d) Give the field that could be amended to contain Boolean data. Computer_type
(e) Name and describe the most appropriate validation check other than a length check
which would be carried out on the Processor_type field. Format check L0000
12
Unit -18 Data types and Organization
Q(7)Many database software packages have a report generation feature. The following is part
of a video hire shop database showing films available in Blu-ray format.
(a) Each of the following fields contains data that is numeric. Give a more precise data type
for each of these fields.
Price …………………………………………………………………………
Length ……………………………………………………………………….
(b) Blu-ray discs have one of three region codes or are region-free. Describe how the field
Regions could be set up to reduce the possibility of inaccurate data entry.
(c) Describe, in detail, how you would create a formatted report which does not show
regions and only shows films which are longer than 110 minutes.
13
Unit -18 Data types and Organization
Q(8)Enrique has developed a new database system for a supermarket. Below is one record
from the database. He needs to test the validation checks that he has developed for the
system.
a) A length check is set for the Barcode field. However, when he entered the code
5012472141308 by mistake, the system still accepted it. Describe the check he could
have used to prevent this error.
a) The Reorder_level for each item is never more than 100. He developed a validation
check to make sure this is the case. However, when he entered the number 100 it was
rejected. Name and describe the validation check he should use and explain why the
number could have been rejected.
a) He also designed a length check for the Supplier_code field. However, when he entered
EZQ23 by mistake, the system still accepted it. Describe how he could have prevented
this error.
d)For each field write down the most appropriate data type. For any numeric field specify
the type of number.
Barcode ……………………………………………………….. Price ………………………………………………………..
Supplier_code ……………………………………………. Reorder_level ……………………………………..
Contents ……………………………………………………. Weight(kg) …………………………………………….. 14
Unit -18 Data types and Organization
Q(9)Just-discs Limited stocks many music CDs. Below is a small selection of CDs stored on
their database. The data has been sorted on two fields.
a) Write down the field which was used as the primary sort in the database and the order
in which it was sorted.
b) Write down the field which was used as the secondary sort in the database and the
order in which it was sorted.
15
Unit -18 Data types and Organization