help for Generate a Buyer code

David Brown
Fri, 21 Jun 2002 11:39:37 +1000

> Creating a unique code like this will get you into a lot of trouble as
> soon as you have more than 100 buyers from a particular are with the sam=
> surname, eg Smith or Ng.  You also have problems if people change their
> name.  Use a unique number generator instead, eg a
> sequence or auto-increment field.

Oliver, you're making a big mistake assuming that his table is keyed this =
way. In real systems, there are plenty of times when you want a code that'=
s human-friendly, and a unique number generator will hardly deliver that. =
Whether he chooses to make it the primary key is another story, although t=
here are business cases where this too is perfectly legitimate (contrary t=
o what some people say).

It is entirely normal to assign meaningful codes to trading partners, and =
as you would expect, these need to be unique, at least for current records=
=2E On the other hand, I agree that his algorithm is a bit dodgy.

Peter, how many cities and buyers are you talking about here, and are most=
 of the buyers concentrated in one city, or spread fairly evenly? In other=
 words, how many duplicates do you get without the two digit suffix?

Is Oliver's suggestion that you use numbers rather than alphanumeric codes=
 okay? If not, is it the primary key? I think the solution will depend on =
your answers.