insering data with existing primary key
Posted: Tue Sep 08, 2009 8:26 am
What will happen if user insert data with same primary key?
Will it thhrow error ?
how can i solve this?
Will it thhrow error ?
how can i solve this?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Assuming your using an id, no harm in using a string as a primary key. For example, what about a username for a users table. The username would work perfectly as a primary key, and would remove the overhead of having an id.onion2k wrote:Users shouldn't be choosing primary keys.
And would break everything if the user wanted to change their username.AlanG wrote:Assuming your using an id, no harm in using a string as a primary key. For example, what about a username for a users table. The username would work perfectly as a primary key, and would remove the overhead of having an id.onion2k wrote:Users shouldn't be choosing primary keys.
Hmm would it? If it did I would put that down to bad development or database design. Personally I use an id all the time. It makes it easier when passing it around such as in urls and such, no need to worry about url encoding it.onion2k wrote:And would break everything if the user wanted to change their username.