Chapter Four
4.1 Introduction:
Data can exist in many forms, and so there are various defined types of data that computers use. All the data that is stored on computers is digital, but lots of types of data in the real world involve physical measurements of continuously varying data. These need to be converted into digital data for storage and manipulation on a computer.
Data frequently needs to be stored in a logical sequence to allow access and/or searching to be done at some later stage. One of the most common methods of data storage is the use of databases.
4.2 Types of data:
There are several data types found in most computer systems:
- logical/Boolean
- alphanumeric/text
- numeric
- date.
Logical/Boolean data:
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. The AND operator Consider the list of seven students in Table 5.1.
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). The OR operator 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).
In the student database example, C, D, E, F and G contain items which are true in either group.
Alphanumeric and text data:
Looking at a standard keyboard, you see the letters A to Z, the digits 0 to 9 and other characters such as : @ & £ ) } etc. The letters A to Z are referred to as text and the letters A to Z plus the digits 0 to 9 are referred to as alphanumeric (some definitions also include the remaining keyboard characters such as @ & £ ) } as part of the alphanumeric character set). 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.
Numeric data:
Numeric data can be in two forms: integer (whole numbers) or real (containing decimals). For example, 3416 is an integer, but 34.16 is real. Examples of integers include the number of floors in a hotel, the number of students in a class or the number of wheels on a car. Examples of real numbers include temperatures, price of an item in a shop or a person’s height in metres.
Numeric data also includes zero (0) and negative numbers such as – 4516 (integer) or – 30.26 (real).
Date data:
Date can be written in many forms, for example:
- dd/mm/yyyy (dd = day, mm = month and yy/yyyy = year), e.g. 19/08/2009
- dd/mm/yy, e.g. 19/08/09
- dd.mm.yy, e.g. 19.08.09
- yyyy-mm-dd, e.g. 2009-08-19.
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:
- dd mmmm yyyy, e.g. 19 August 2009
- dd-mmm-yyyy, e.g. 19-Aug-2009.
All the above are accepted as date in most application packages (such as spreadsheets and databases) where the format is particularly important due to data manipulation (e.g. sorting) or searching.