id,fname, lname, gender Login -> id,email, username, password" />
开发者

MYSQL : Two tables "Signup" and "Login" ? Is it good to make them a single table or keep them two different Table

Two tables "Signup" and "Login" ?

  • Signup -> id,fname, lname, gender
  • Login -> id,email, username, password

In php I need interact with onl开发者_StackOverflow社区y Login table. But during sign up through php will I have to use two insert queries to insert into both tables.

I want to reduce number of queries and also want to optimize database.

I make signup+login = single table .... is this good idea, as when I login, I will have interact then a large single table


It is a good idea if there is a one-to-one mapping of login and signup information. You get better performance with one id lookup. Maybe a "Users" table?

On a sidenote, I hope by "password" is not a clear text password field and is instead a hash of the password. You should never have clear text passwords stored anywhere.


I think if you have less than 1,000,000 entries in your database table or even less than 10,000,000 entries and the right indexes it should be no problem to handle this data in one database.

I would save the data in one table and set a flag for new users, which haven't verified their account by email activation, yet. So for the login-query I would add "WHERE ... AND verified = 1" or something like this to disallow new users to login.

I've a database table which contains nearly 15,000,000 entries with 27 fields and which is 1,9 GB large. With some indexes set I can send a query and receive the answer within 0.2 - 0.4 seconds...


I mostly agree with amccausl & ispcity but keeping unverified signup data and verified signup data separate can be a good thing for security, doing that means that anyone with malign intent who does not have a verfied id only ever has access to the table containing the unverified data rather than the data belonging to all your 'real' users.

As ispcity points out, performance is not likely to be a problem in any case but it would also be straightforward to have the copying of the data (from the 'signup' to the 'verified' tables) carried out by the (presumably offline) program that sends the verification email rather than during the signup process.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜