CCNC/CCNC Module 5/The database application/Database Concepts/Data Types

From WikiEducator
Jump to: navigation, search
Tutorial.png Database Concepts 

What is a Database | How a Database is Organized | Data Types | Normalization | Self Assessment | Summary & FAQs


Data Types

Icon objectives.jpg

Outcomes

Upon completion of this tutorial the learner will:
  • Discuss and apply different data types to attributes
  • Describe the difference between mandatory and optional attributes


The basic data types

When designing a database table you will need to decide on the data type for each field. There are four primary data types available, they are;

  • Text
  • Numbers
  • Date Time
  • Binary

These data types then break down into more specific types within each primary type. For the OpenOffice Database the following types are available;

Text - character (and alphanumeric) data

  • fixed - a fixed length string of text (or alphanumeric) characters
  • varchar - a variable length string of text (or alphanumeric) characters

Numbers - numeric data

  • Boolean - single digit representing either yes or no
  • Integer - and integer or whole number (i.e. without decimal places)
  • Float - a number with decimal places

Date Time date and time data

  • Date - a character string specific for storing dates
  • Time - a character string specific for storing time
  • Date/Time (timestamp) - a field specifically designed to store a date and time stamp

Binary - large amounts of binary data

  • Image - a large amount of binary data in the form of an image (i.e. gif, jpg, etc.)
  • Memo - a large amount of text
  • Binary - similar to an image field, used to store anything binary (i.e. mp3, ogg, avi, etc.)

It should be noted that this is not a full description of the available data types and how they can be used. It is the beginning of an extensive topic and beyond the scope of this course.

Mandatory and optional fields

When designing a database table you should always ask yourself if the field (or attribute) is mandatory or optional. In other words, can the field be left empty? The answer to this question varies from database to database depending on the information needs. An example would be a persons birth date; if the situation requires that decisions are made on the age of the person, then birth date would be a mandatory field. The other side of this issue would be when would you like a field to be optional? Answer: When not all data is available at time of data entry... Remember to give the mandatory and optional issue some thought as you build database tables.

test your knowledge



Icon qmark.gif

Data Types

 

1. The best data type for a TRUE / FALSE value is?

(a) Text.
Incorrect, click here to review the topic.
(b) Integer.
Incorrect, click here to review the topic.
(c) Numberic.
Incorrect, click here to review the topic.
(d) Boolean.
Absolutely Correct!

2. postal code would be considered why kind of data type?

(a) Mandatory.
Incorrect, click here to review the topic.
(b) Optional.
Incorrect, click here to review the topic.
(c) Alphanumeric.
Incorrect, click here to review the topic.
(d) Both a and c.
Absolutely correct!
(e) Both b and c.
Incorrect, click here to review the topic.

3. A music file would be stored in a binary data type?

TRUE.
Absolutely correct!
FALSE
Incorrect, click here to review the topic.

Your score is 0 / 0