On Sunday 22 December 2002 08:14, Michael Conway wrote:
> I have been working on an e-business project and have a product table
> and manufacturer table that are linked via barcode and a manufacturer ID
> (both primary keys in the tables mentioned).  For now, I have been
> setting the manufacturer's ID manually, primarily for that rare instance
> where a manufacturer and its products are dropped from the database, but
> the number should be reused.

The question is _why_ do you want/need to reuse the ID?

> Is it better or possible (without
> complications) to use autoincrement and simply delete the product
> information and manufacturer information while leaving the ID column
> intact for a later update operation with a new manufacturer and its
> products? 

Again, _why_ would you want to do that?

I'm guessing that you want to IDs to look nice, running sequentially from 1 
with no breaks in between?

The whole point of using autoincrement is that it is guaranteed to give you a 
unique ID.

> I suppose only one table (the linking table?) should be set to
> autoincrement and that ID number used to populate the remaining tables
> depending upon that number for insert operations.  The code is probably
> simple, but my head is already swimming.  I suppose what I am looking
> for is "best practice" advice from seasoned db administrators.

I think the best advice is to get used to the fact that breaks in the sequence 
of IDs are no big deal. The IDs are there to be used internally by your 
application to link tables together.

Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

This ASEXUAL PIG really BOILS my BLOOD ... He's so ... so ... URGENT!!

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to