We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Large database design

Hello

Just a short question, about how you would do this:

Let's say I have 1 million users, and i need to store data about this user, like success_logins, attempts, remember_tokens, email_confirmations and so on

Would you make one table for every one OR would you make a usermeta with user_id, key,value with user_id and key is indexed - Wich will be best in the long run?

edited Apr '18

Well, the 2nd one would only be useful if your schema can change during runtime,

Otherwise, I'd stick to explicitly defined tables/columns

Performance-wise, i dont think there will be substantial difference (but that's just an educated guess, presuming innodb and sane queries)

I would say any data you're only storing 1 of, keep in the user record. So if there is only 1 remember token, 1 email confirmation, keep it in the user record. If you need to track multiple tokens or other datum, normalize that out into another table.