Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having a Login ID and a PersonID in SQL

I am creating an application that will require a user to register and create an account.

Should I use the person's Login ID (this is the email address) as the unique record identifier or should I also create a PersonID (or rec_id).

Why should I (or should not) create a rec_id ?

like image 795
LearningCSharp Avatar asked Jul 21 '11 07:07

LearningCSharp


2 Answers

If you use the email address as a primary key in the Person table and foreign key in the related tables, it will be hard to implement the Change Email feature - instead of a single update, you will be forced to add a new record to the Person, update all the related records and then delete the record with old email.

like image 163
Marek Grzenkowicz Avatar answered Oct 19 '22 20:10

Marek Grzenkowicz


Of course the person's mail address usually should be unique. But an additional record ID can be used as foreign key in other tables and so will make table joining much easier.

like image 40
Timo K. Avatar answered Oct 19 '22 19:10

Timo K.