An organised set of data is usually referred to as a database.

Databases can be a little difficult to understand, so I'll try to illustrate the concept with a few diagrams.

We will use some student data as an example.

Here are our students...
Databases can be found at the heart of almost every computer system:
  • Databases of users
  • Databases of files
  • Databases of webpages
  • Databases of blog entries
  • Databases of photos
  • Databases of products
Databases are everywhere!
stacks_image_F5BC24AB-411F-42E5-B95F-52FFD13F4228
ID No.: 356
Name: Jess
D.o.B.: 3 Mar 1995
Phone: 7564356
Class: 5B
Tutor: Mr Noggin
Room: 56
ID No.: 412
Name: Hamad
D.o.B.: 12 Nov 1994
Phone: 7465846
Class: 5B
Tutor: Mr Noggin
Room: 56
ID No.: 459
Name: Sita
D.o.B.: 9 Jan 1994
Phone: 8565634
Class: 6Y
Tutor: Ms Take
Room: 18
ID No.: 502
Name: Hamad
D.o.B.: 3 Mar 1995
Phone: 6554546
Class: 5B
Tutor: Mr Noggin
Room: 56
You'll see that each student has some data associated with them (name, d.o.b., etc.) We want to store this data is an organised way so that we can easily access it in the future. We want to create a student database.

So, how should we organise this data?

What is a Record?

The set of data associated with a single object or person is known as a record.

In the example of our students, the data associated with each student is a record.

Here is Jess's record...
stacks_image_0656D70B-D4B2-47CB-A307-F5D9E64F27F3
Each student has their own record just like Jess's but with different data.

The data in each record is different, but each record has the same structure. (each one has a name, d.o.b., phone, etc.)

We say that each record contains the same fields.
A database is a collection of records.

You can imagine a single record being a card with one the details of one person/object written on it.

A database would be a boxful of these record cards...
stacks_image_536676DC-B8D8-4F2B-9452-AB874EF79D23
This is exactly how a lot of old, manual databases used to look. If you went to a public library 30 years ago, and you wanted to find a specific book, you would have to look through boxes of index cards until you found the details of your book.

What is a Field, and What is a Field Name?

You'll see that each of our student's records contain the same items. These items are known as fields.

Each field has a field name (e.g. 'Date of Birth')

Each field will contain different data in each of the records (e.g. in Jess's record, the Phone field contains 7564356, but in Sita's record the Phone field contains 8565634 - same field, different data values)

It can be a bit confusing - what's the difference between the field, the field name, and the data in the field?!

Imagine that you were manually filling in a record card for Jess. The card would have various labels and boxes to write in...
stacks_image_A50B5326-6041-487E-B1B9-429C2BBB4B51
  • The field is the box that you would write in
  • The field name is the label next to the box
  • The data is what you would write in the box
Each of our student records contains seven fields:
  • ID Number
  • Name
  • Date of Birth
  • Phone Number
  • Class
  • Tutor
  • Room

What is a Key Field / Primary Key?

It is very important that every record in a database can be individually identified. We need to be sure that when we access a record, we are accessing the correct one.

Take a look at our students - what item of data identifies them from all of the other students?
  • Name? No - we have two Hamads
  • Date of Birth? No - Jess and Hamad share the same birthday
  • Phone? No - two or more students may live at the same address
  • Class / Tutor / Room? No - each class has many students
Because all of these fields might contain the same data for more than one record, we can't use them to identify each record.

So... we have given each student an ID number. We can guarantee that this number will be unique for every student.

The ID number is the ideal field to use to uniquely identify each individual record. We call this field the Key Field, or Primary Key.
stacks_image_38EB154A-8E3B-4FA0-855D-C5160FA75A35
It is usual for a code or ID number to be used as the key field.

In the example, we could have used the student name as the key field, but this would be a bad idea.

Why? Because two or more students might have the same name, so the name would not identify each student uniquely.

Database Viewed as a Table

It is quite common to view the contents of a database as a table instead of one record at a time. A tabular view is compact and allows you to see a lot of records in one go.

Our student database would look like this...
The tabular view of a database is is exactly the view that you see when working with your database software (e.g. Microsoft Access).
stacks_image_18977385-DB04-4716-BA08-939B9A5ADE18
Each row of the table corresponds to a database record...
stacks_image_9BC104D9-C135-463D-B4C5-ECABACCB7011
The column headings correspond to the database field names...
stacks_image_D30BCCC4-9E87-42FF-A8AE-D4EF477D4E1F
Each cell of the table corresponds to a field, and contains an item of data...
stacks_image_5644C196-C536-44C6-BA06-98D336C7535F