开发者

Help setting up MySQL Database

开发者 https://www.devze.com 2023-03-03 15:39 出处:网络
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. Th开发者_JS百科e user account would have the key

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. Th开发者_JS百科e user account would have the keys:

  • First Name
  • Last Name
  • Email Address
  • Username
  • Password
  • Date of Last Login.

I would really appreciate it if you could tell me what the schema should look like for it.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消