Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Would you use one or two tables for username and password?

Is it any safer to create a table holding user information and another one for their passwords than using the same table for everything?

like image 879
expora Avatar asked Apr 28 '10 07:04

expora


2 Answers

No I would just do this:

id, username, password.

Where id is just autoincrement, username is a varchar of 20 (or so, depending on your needs) and password is an MD5 or SHA1 hashed password with a salt.

Using two tables for this just doesn't make sense. Then you need to work with joins to get the data. And that's just an unnecessary burden.

like image 125
Snake Avatar answered Nov 09 '22 03:11

Snake


No, I cannot see how that can make it safer.

You should actually refrain from storing passwords at all. Just store their salted hash.

Further reading:

  • Stack Overflow: Preferred Method of Storing Passwords In Database
like image 21
Daniel Vassallo Avatar answered Nov 09 '22 04:11

Daniel Vassallo