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.
using autoincrement id
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: using autoincrement id
- 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.
- 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.