MORE ON DUPLICATES
with Fabian Pascal

 

 

 

From: CB

To: Editor

Date: July 9, 2003

 

I read with great interest the "Double Trouble" articles on your site.

 

One question remains, however: what is the proper way to represent two or more identical objects in a database - say, for example, in an Orders database where two identical cans of cat food were ordered by a customer?

 

My guess is that you would do it one of two ways, as shown here:

 

===========================================

ITEM                PRICE       SEQUENCENO

===========================================

Cat Food      0.39                       1

Cat Food      0.39                       2

-------------------------------------------

 

Or:

 

==================================

ITEM         PRICE       QUANTITY

==================================

Cat Food      0.39           2

----------------------------------        

 

But I could be wrong.  Please enlighten me.

 

 

From: Fabian Pascal

To: CB

 

Read the chapter on duplicates in my book.

 

The short answer is that you are confused conceptually; there IS no such thing as "two identical objects". If they were identical, they you would not be able to distinguish between, or count them. The fact that you can means that there is something that distinguishes them and if you want to keep track of them individually, you MUST represent that distinction in the database. If you do not, you are contradicting yourself.

 

 

From: CB

 

Thanks.  I will read your book when I get a chance.

 

But on a practical basis, how would you represent the fact that a customer purchased 2 cans of cat food on a given date, as a part of one order?

 

 

From: Fabian Pascal

 

You have only two options, anything else confuses the issue and introduces inconsistency.

 

·   either you want to track them individually, in which case you must distinguish between them, so you use a surrogate key;

·   or you don't need to track them individually, then you record the lot with an attribute QUANTITY=2;

 

This is explained in detail in the book – reading the book is the practical basis.

 

 

Posted 09/26/03

 

 

 

[ABOUT] [QUOTES] [LINKS]