Re: Auto Increment
| From: | Miles Thompson | Date: | Sat, 10 May 2003 01:20:01 +0000 |
| Subject: | Re: Auto Increment | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27629@lists.php.net to get a copy of this message | ||
I would say that generally it's a good thing as it provides a unique key for each record. (I believe one of Codd & Dates's 12 rules for a relational database was that each record had to be uniquely identifiable, or something like that.)
Is it necessary? No, not really, and does impose a minor performance hit.
I generally use auto-incremented primary keys on tables where there are definite parent-child relationships. These keys can be used in the background avoiding any future complications where a client decides to redefine the serial number or similar value often used as primary key. Thus you are pretty-well protected against changes to data fields, whihc means logic isn't broken, etc.
For lookup tables and the like I don't bother with auto-incremented keys.
Regards, and I hope this helps - Miles Thompson
At 11:38 PM 5/9/2003 +0100, shaun wrote:
Hi, I seem to be putting an auto increment id field in all my tables, is this a bad thing? If so when should and shouldn't they be used? Thanks for your help -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php