Page 1 of 1

using autoincrement id

Posted: Sun Mar 06, 2011 9:12 am
by meee
I am wondering if it is recommended to use autoincrement fileds even if I don't need it?

As for example I have tables users, companies and employees. Inside table employees are user that joined a company.

The structure of table employees is as the following:
fieldId | companyId | userId | levelAccess

In this case filedId is just autoincrement without any value, it is just for the my record and it could be just without.

So should I remove fieldId from the table?

This was just one example of table where I don't need autoincrement id. I hear one time from somebody that he use autoincrement id in all tables. That is why I put it, but I am not sure if this has any sense.

Re: using autoincrement id

Posted: Sun Mar 06, 2011 9:24 am
by John Cartwright
- If you never need a unique id for the record, then don't use it.
- If you may need to join the data from another table, it is always far faster to use an auto-inc primary key to perform the join.
- If you need to look up individual records, then use it.