0% found this document useful (0 votes)
258 views

Unit 18 - Data Types and Organization

The document discusses different data types used in databases including numeric, text, date/time, Boolean, and organizational structures like records, fields, keys, tables, and relationships. It provides examples of each data type and structure. Validation methods are described to check data including length, format, range, type, and presence checks. Sample database tables and questions are included to illustrate concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
258 views

Unit 18 - Data Types and Organization

The document discusses different data types used in databases including numeric, text, date/time, Boolean, and organizational structures like records, fields, keys, tables, and relationships. It provides examples of each data type and structure. Validation methods are described to check data including length, format, range, type, and presence checks. Sample database tables and questions are included to illustrate concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Unit -18 Data types and Organization

Different Data Types


Numeric Data – Integer
It is a whole number - it has no decimal or fractional parts.
It can be either positive or negative.
Numeric Data – Real
It includes whole numbers (integers) and numbers with decimal/fractional parts. Real numbers can
be positive or negative.
Numeric Data – Currency
Numbers formatted with a symbol.
Numeric Data – Percentage
Fractional numbers formatted with a percentage sign.
Different Data Types
Text/Short Text/Alphanumeric Data
Data made up of letters, numbers, symbols ($%^+@, etc.) and spaces are also allowed.

Date and Time Data


Date (and time) data is formatted in a specific way. The format depends upon the setup of the
computer, the software in use and the user’s preferences

Boolean (Logical) Data


Boolean data can only have two values: TRUE or FALSE . YES or No, ON or OFF, Male or Female

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.

Note that to create the


relationship, we are using the key
field (primary key) from one table
to link it to another.
When a key field from one table
appears in a different table, we
call this a foreign key.
4
Unit -18 Data types and Organization
Data Verification:
1) To check whether the data has been typed correctly.
2) What ever was supposed to be typed has been typed or not.
3) It is also to check whether data has been accurately copied from one medium to
another but it does not check that data is correct.
4) Verification can be used to help make sure that the data in your database contains
as few mistakes as possible.
5) It can be carried out by the user or even by the by the computer.
The two methods are
a) Visual Verification: Read through the data after it has been typed. This is done by the
user. It is quick but not that accurate as the user may overlook. (example typing an
account number, email id, student information in the database)
b) Double entry: Data has been typed twice and the software compares the two sets of
data. (Example: Password)

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.

(a) How many records are there in the book file?


(b) How many fields are there in the borrower file?
(c) What type of database do these two files form?
(d) Give two reasons why this type of database system is used rather than having
two flat files.
(e) Which field is the primary key in the Book file?
(f) Which field is the foreign key?
(g) Which field has the data type currency?
(h) What data type would be most appropriate for the Due Back 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

Format check : Flight_number LL000

Length check : Departure_Airport_code field size 3 , LLL

(b)Using the extract above, give an example of one field which would contain:

Text data: Flight_number


Numeric data : Number_of_passengers

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

Question Write down three features of a flat file:


 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.

Why is relational database more effective method of handling data?


• 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.
• No repeated data, so table size is small.
• No repeated data, so records can be accessed quickly.
• Tables can be added at any time.
• Individual records in each table can be added provided the linked field has not been
disturbed.
16

You might also like