# 5.5: Data Hierarchy

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

A relational database is composed of multiple tables, and each table holds data. Within a table, each row represents a group of related data values. A row, or record, is also known as a tuple. The columns in a table is referred to as a field or attribute. A record is one instance of a set of fields in a table. You can also think of it this way-an attribute is used to define the record and a record contains a set of attributes.  A data hierarchy is the structure and organization of data in a database and an example can be seen below.

Group Description
File a collection of related records. i.e. all student information (ID, name, major, email)
Record a collection of related fields. i.e.John Smith’s ID, major and email
Field holds a single fact or attribute. i.e. student name
Byte a unit of digital information 1 byte = 8 bits representing a single character
Bit unit of measurement to quantify computer data. Single value of 0 or 1

## Data Types

When defining the fields in a database table, we must give each field a data type. For example, the field ‘StudentName’ is text string, while ‘EnrollmentCapacity’ is number.  Most modern databases allow for several different data types to be stored. Some of the more common data types are listed here:

Data Type Description
Text for storing non-numeric data that is brief, generally under 256 characters. The database designer can identify the maximum length of the text.
Number for storing numbers. There are usually a few different number types that can be selected, depending on how large the largest number will be.
Boolean a data type with only two possible values, such as 0 or 1, “true” or “false”, “yes” or “no”.
Date/Time a special form of the number data type that can be interpreted as a number or a time.
Currency a special form of the number data type that formats all values with a currency indicator and two decimal places.
Paragraph Text this data type allows for text longer than 256 characters.
Object this data type allows for the storage of data that cannot be entered via keyboard, such as an image or a music file.

There are two important reasons that we must properly define the data type of a field.

1. First, a data type tells the database what functions can be performed with the data. For example, if we wish to perform mathematical functions with one of the fields, we must be sure to tell the database that the field is a number data type. For example, we can subtract the course capacity from the classroom capacity to find out the number of extra seats available.
2. The second important reason to define data type is so that the proper amount of storage space is allocated for our data. For example, if the ‘StudentName’ field is defined as a Text (50) data type, this means 50 characters are allocated for each name we want to store.  If a student’s name is longer than 50 characters, the database will truncate it.

This page titled 5.5: Data Hierarchy is shared under a CC BY-SA license and was authored, remixed, and/or curated by David T. Bourgeois (Saylor Foundation) .