C5 - Data Types
C5 - Data Types
Learning Outcomes:
In this chapter you will learn about:
● types of data – Boolean, text, alphanumeric, numeric and date
● data structures – files, records, fields and primary keys
● relational databases – tables, primary keys and foreign keys
● analogue data – the need for analogue to digital convertors (ADC)
● digital data – the need for digital to analogue convertors (DAC)
Introduction:
Activity:
Analysis:
Abstraction:
5.1 TYPE OF DATA
There are several data types found in most computer systems:
● logical/Boolean
● alphanumeric/text
● numeric
● date
Boolean data (or logic data type) can have only two values: true or false.
This works if there are only two possible responses to a question or situation, i.e.
(Yes or No), (True or False) or (1 or 0).
This is made most use of when carrying out a search in a database or on the
internet. In these cases, logical operators are used which are based on true (i.e.
binary 1) or false (i.e. binary 0) logic.
Suppose we now make the search: (Sex = Male) AND (Height (m) > 1.6)
Table 5.2 shows the logic status for each part of the search query. There is only one
match where the search condition is true for (Sex = Male) AND true for (Height (m)
> 1.6): name B.
Note that the logic operator called AND looks for the situation where
something is true in both groups. For example, consider two groups X and Y where
X = {1, 2, 3, 4} and Y = {3, 4, 5, 6}. The statement X AND Y would be equal to {3,
4} since it is true that 3 and 4 are the only items which are common (i.e. true) to both
groups (see Table 5.3).
In the student database only example B contains items which are true
(common) to both groups (i.e Male and 1.7m).
Now consider a different search: (Sex = Female) OR (Height (m) < 1.6) This gives
the logic status shown in Table 5.4. There are five matches where the search
condition is true for (Sex = Female) OR true for (Height (m) < 1.6): names C, D, E,
F and G.
Note that the logic operator called OR looks for the situation where
something is true in either group. For example, consider two groups X and Y where
X = {1, 2, 3, 4} and Y = {3, 4, 5, 6}. The statement X OR Y would be equal to {1, 2,
3, 4, 5, 6} since it is true that all six numbers occur in either group (see Table 5.5).
For example, the password ‘MARQUES’ contains letters only and is therefore
text. However, the password ‘MIKE62’ contains letters and numbers and is therefore
alphanumeric. A person’s name would always be text but their address, which could
contain letters and numbers, would be alphanumeric.
5.1.3 Numeric data
All of the above examples use a number form of the month, but it can also be written
as the full word or the three-letter abbreviation:
Figure 5.2 shows a possible structure for the file COMPANY EMPLOYEE
FILE. The information is held in one file with five records and four fields per record.
In this example, the first field (the reference number) is known as the key field or
primary key. Each primary key is unique and is used to locate a record in a file
during a search operation.
Also note the data types for each field:
5.3 DATABASES
Relational databases
Relational databases do not need to repeat data, which is one of the problems
of flat file structure (in the example that follows, three flat files would be needed
containing repeated fields of key data since there would be no links connecting each
file). Information is stored in separate tables only connected by the primary (key)
field. Other advantages of relational databases include:
Tables can also contain foreign keys that relate tables in the database to one
another. A FOREIGN KEY in one table is a primary key in another. We will now
look at an example that shows the structure of tables in a relational database. In this
example, there are three connected tables. It is important to note that in commercial
databases there will be several tables connected together. The examples shown here
contain only two or three and are being used to show the principle of relational
databases.
Example
A garage sells cars and keeps a database of sales, customers and servicing, as shown
in Figure 5.4 overleaf.
The primary (key) field is Car number and the column is shaded red).
The foreign key fields are Invoice number and Engine ID and these are
shaded green.
Information from all three tables is linked together so, for example, if a car
service was due then by typing in Car number the customer’s details and servicing
details are brought up on the screen. This means information can be sent to the
customer as a reminder. Once the service is carried out, the servicing table will be
updated which means all other references to it will also be up to date.
As we have already learnt from earlier chapters, computers work with digital
data, which is defined as discrete, fixed values in a given range.
However, in the real world, physical measurements (i.e. data) are not digital
but are continuously variable, producing an infinite number of values within a given
range. For example, length, weight, temperature, pressure, etc. can take any value,
depending on the accuracy to which they are measured. These values are measured
by an analogue device which represents physical measurement on a continuous
analogue scale, as illustrated in Figure 5.5. The speedometer represents speed by
showing the position of a pointer on a dial, while the thermometer represents
temperature by the height of the liquid column.
This example shows why there is a need to convert analogue to digital and
also digital to analogue as part of control system involving a computer:
Application:
References:
IGCSE
Information and Communication Technology
Graham Brown and David Watson
Congratulations! You did a great job for this lesson! You can now proceed to the next
lesson.