NYCPHP Meetup

NYPHP.org

[nycphp-talk] primary key alphanumerical

inforequest 1j0lkq002 at sneakemail.com
Thu Dec 9 17:57:13 EST 2004


jaime bermudez jaimeb82-at-yahoo.com |nyphp dev/internal group use| wrote:

>Hi there,
>Is there any way to make a Primary Key that is a
>combination of letters and numbers. I have an
>application form that collects teachers information,
>then every teacher should submit their school
>principal and their school supervisor, the problem is
>that each (PK) is just a consecutive number.
>Therefore, each application contains 3 diferent
>numbers like 001 (for the teacher) 002 (for the
>principal) and 003 (for the supervisor) this gets
>confusing when I try to separate them to transfer from
>MySQL into an Access database. It would be ideal if
>they are something like that : TEA001, PRI001, SUP001,
>etc...
>
>Any ideas or paths so I can start researching...?
>
>Thanks in advance, Jaime.
>Gilder Lehrman Institute of American History
>  
>


I echo the comments about exercising care normalizing the data. What you 
seem to be describing is a need for labels, which is best addressed with 
display features or lookup tables. When you add TEA to the data  as you 
describe, you are actually encoding the "teacher" data twice, which is 
dangerous for technical/management reasons. You are also hard-coding an 
assumption into your dataset (that 001 is "teacher") and that removes 
some of the flexibility you got when you chose to use a database in the 
first place.

I'd suggest you have a database expert look over your table design and 
maybe your queries before you advance too far. It maybe very much worth 
the minor inconvenience.

-=john andrews







More information about the talk mailing list