Simple clear advice in plain English

Hands on: Database values

Discover how to overcome problems when you don’t know what value to enter

Ironically, one of the more challenging database problems is not what to do with the data, it’s what we do when we don’t have the data.

Suppose we have a field that is designed to store the number of children for each customer. We set it up as an integer field and start entering data.

When we reach David we realise that we simply don’t know the answer. The immediate temptation is to enter 0 (see attached picture).

The problem is that zero is a number just like 1, 2 or 3. In this case, since we don’t know how many children David has, entering zero is likely to be as inaccurate as entering any of those other values.

Indeed, if we run a query to find the average number of children for our customers we can see that zero is a bad entry. We have six customers for whom we have data. They have 12 children between them, so the average is 2.0 but given this table we get an answer of 12/7 = 1.7.

To cope with this kind of problem, the database world invented the ‘null’ value. If we don’t enter a number here (or delete the zero), then Access enters a null value. A null means, in essence: ‘We don’t know what this value is.’Databases do not treat nulls in the same way as other values. By which I mean, for example, that if we run the query again, Access notices that although we have seven rows of data we only have six values. So it divides the total (12) by the number of non-null values (6) and comes up with the correct answer.

Up, up and away
Upsizing is the gentle art of moving a database from one database engine to another, usually a client-server system. I recently looked at two upsizing tools, SSMA from Microsoft and Must from ASC Associates. Both are useful to have when upsizing from Access to SQL Server, but it is important to realise that no matter how good the upsizing tool, you need to have your brain switched on during the operation. The reason is that databases often have, encoded in their structure, the interaction between the problem we are trying to solve and the features of that particular database engine. An example may help to make this, admittedly somewhat abstract, point clearer.

The problem
You need different people, in different locations, to enter data into an Access database, so you give each person a different copy of the database. You will consolidate the data later into one database. Each new record needs a primary key value that is guaranteed to be unique, but how can you guarantee uniqueness when they are all using different copies of the database?

The solution
Access can generate GUIDs (Global Unique Identifiers). These were mentioned in the October column: usually implemented as Autonumber fields and used as primary keys, GUIDs are unwieldy strings with a very high probability of uniqueness.

Article tags

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

Using Wizard to create a form

Create a good Base for your data

Databases may sound very dreary but they are behind almost everything we do. We explain how to go about starting one of your own using Libre Office Base

Blog illustration

Create a Wordpress blog

Blogs are a great way to share news and opinions online. In the first article in our two-part series, we show you how to set one up and update it

f-340-hifi-spotify

Rip and save music in high-quality formats to listen to on your PC

How to keep the sound quality high using a lossless format

Question & Answer

Q.How do I store musician and other information about...

> Read the answer

Q.Why can't my browser find the website address I typed...

> Read the answer

Q.All updates have been downloaded, so why won't Windows...

> Read the answer

Best deals on the web

img

Apple MacBook Pro (MC724LL/A)

£999.99- Buy it now

img

Sony Vaio VPCF23P1E/B

£679.98- Buy it now

img

Samsung 300E5A-A01DX

£449.99- Buy it now

Great benefits for subscribers!

Most popular articles

Poll

Which is your preferred web browser

Jargon Buster

Computing terms explained in plain English

VoIP

Voice over IP. The routing of voice conversations over the internet, which is cheaper than the telephone...

Great shopping deals from Computeractive