Data Types & Validation

Databases can use a number of different Data Types. The typical ones are listed below:

Data Type

Explanation

Short Text:

No more than 255 characters

Long Text:

Longer strings of text like paragraphs

Number:

These fields can be used for doing calculations

Date/Time:

E.g. Date of Birth or Reservation Booking time

Currency:

Any currency can be chosen e.g. AUD $

AutoNumber:

Stops numbers from being repeated - each time a new one is allocated.

This Field is often used as a Primary Key (see below)

Yes/No

This field can only be one thing or the other .e.g Male / Female

OLE Object:

Useful for things like Images e.g. Employees Photo

Hyperlink:

Can link to a website or document

Setting a Primary Key

The Primary Key is a very important part of a Database. It is a special Field that contains data that is unique for each record.

A car dealership may use a car's registration or number plate as a primary field to set apart two cars of the same colour, make and model.

Everyone has a unique Passport Number that neans people cannot get mixed up.

People have Bank Account numbers so that no one else can access their money.

Can you think of any other placs where Primary Keys might be used?

What is Data Validation?

This is checking that the Data that has been enterd is Valid (the correct type). Data, however, cannot be checked for accuracy by the Database! For example, a Phone number can be limited to 11 digits but his doesn't stop it from being typed in wrong.

Examples of Data Validation

Field Length check – only allows a specific number of characters to be entered.

Range check – number entered must be within a certain range, eg between 1-100.

List check – only specific data can be entered, eg Male or Female.

Present check – the field cannot be left empty.

Input mask – data must be entered in a specific way, eg Dates of Birth entered as DD/MM/YYYY

valid