Most often, people use ID, an auto-incrementing number, as a PK. I currently have a table that includes Name and Email, among other things. Email must be unique. I'm using ID as the primary key, which is also a foreign key in many other tables. When somebody logs in, I need to run the following:
SELECT ID FROM Table1 WHERE email = "you@dot.com";
SELECT * FROM Table2 WHERE ID = ...;
Is there any reason not to just have email as the Primary Key, and just have the following:
SELECT * FROM Table2 WHERE email = "you@dot.com";
or am I forgetting something? Liam Morley
imotic@hotmail.com
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."
SELECT ID FROM Table1 WHERE email = "you@dot.com";
SELECT * FROM Table2 WHERE ID = ...;
Is there any reason not to just have email as the Primary Key, and just have the following:
SELECT * FROM Table2 WHERE email = "you@dot.com";
or am I forgetting something? Liam Morley
imotic@hotmail.com
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."