Topics / Databases / Database Data Types

Database Data Types

Database data types are the attributes that specify the type of data that a field can hold.

Why bother?

It’s important to specify the right data types for your database fields because the computer needs to know what type of values they can store, and which operations can be successfully performed using it. Failure to use the correct database data types may result in you losing the ability to perform sorts, calculations and complex searches using the data.

Example:

When using a database, a student’s date of birth should be stored as a date/time data type. Doing so will allow the students to be sorted into DOB order, their age to be calculated, or complex searches to be carried out based on their age, month or year of birth etc.

Now, here is the issue. The database would actually allow you to store student date of births as a text data type, and it would initially all look fine. The difficulties would happen later on when you tried to perform sorts, searches or calculcations based on the student DOB, they wouldn’t work properly and at this point you may have entered hundreds of students! It’s always better to choose the correct data type right from the beginning.

Common data types

Data types can change from one Database Management System to another, but here is a list usually found in most:

Data Type Description
Number Numbers
Date/Time Date and/or time
Boolean Yes/No, True/False, On/Off (two options only)
Text Text
Autonumber Automaticly generated number
Currency A number formatted to a currency of choice

 

Topics / Databases / Database Data Types