Hi Guys,
Let's say you are building a user table.
Each user is going to get a userID, which is just a unique number for every account. What the number is is inconsequential as long as it's unique.
Would it be best to use the primaryKey/rowID for each userID?
For instance, let's look at a basic table.
userID (int, PK, auto)
userName (varchar255)
email (varchar255)
Is that ok? The UserID would simply autoincrement as records are inserted and the DBMS would decide what ID# was used next.
Or would it be best to determine this record ID # programatically so that I'm not reliant on the DBMS to keep userID's in order. In that case, I would use
rowID (int,auto)
userID (int, PK)
userName (varchar255)
email (varchar255)
The rowID would autoincrease as records were inserted, but I would programmatically decide on a userID prior to the insert. Of course I could enforce unique ID's with the DBMS by making sure the inserted userID is unique during the insert, but if I do things correctly that shouldn't be much of an issue.
Thoughts?
1. Rely on DBMS to create unique ID
2. Create uniqueID externally
Let's say you are building a user table.
Each user is going to get a userID, which is just a unique number for every account. What the number is is inconsequential as long as it's unique.
Would it be best to use the primaryKey/rowID for each userID?
For instance, let's look at a basic table.
userID (int, PK, auto)
userName (varchar255)
email (varchar255)
Is that ok? The UserID would simply autoincrement as records are inserted and the DBMS would decide what ID# was used next.
Or would it be best to determine this record ID # programatically so that I'm not reliant on the DBMS to keep userID's in order. In that case, I would use
rowID (int,auto)
userID (int, PK)
userName (varchar255)
email (varchar255)
The rowID would autoincrease as records were inserted, but I would programmatically decide on a userID prior to the insert. Of course I could enforce unique ID's with the DBMS by making sure the inserted userID is unique during the insert, but if I do things correctly that shouldn't be much of an issue.
Thoughts?
1. Rely on DBMS to create unique ID
2. Create uniqueID externally