Reputation: 24481
I need help setting up my MySQL Database.
I would like the database to have a table called accounts. All user accounts would be kept in that database. The user account would have the keys:
I would really appreciate it if you could tell me what the schema should look like for it.
Upvotes: 1
Views: 122
Reputation: 995
CREATE TABLE `MyDatabase`.`accounts` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`FirstName` VARCHAR( 32 ) NOT NULL ,
`LastName` VARCHAR( 32 ) NOT NULL ,
`Email` VARCHAR( 64 ) NOT NULL ,
`Username` VARCHAR( 32 ) NOT NULL ,
`Password` CHAR( 32 ) NOT NULL ,
`LastLoginDate` DATE NOT NULL
)
This assumes you're using an MD5 hashed password (which is 32 in length). Replace MyDatabase with your database name.
Upvotes: 4
Reputation: 308848
I think you mean user account would have these columns. Certainly they aren't all candidate keys.
No account ID? Wouldn't that be the best unique primary key?
I can see where the columns you proposed would belong in a user/customer table; username and password (encrypted and salted, of course) would be in a credential table. I wouldn't have any of these in an account table. I'd have a foreign key pointing to the user that owned the account.
Upvotes: 0