一次性使用验证码等数据是否应该存放在同一个表中
当用户注册帐户时,我会发出一个验证码,稍后用于验证帐户。验证后,该帐户将被标记为 verified=1
并且验证码将被删除。验证码这样的数据是否应该放在单独的表中?
When a user registers an account, I issue a verification code that is later used to verify the account. Once verified, the account is marked verified=1
and the verification code erased. Should such data like the verification code be placed in a separate table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您打算存储一些其他数据,如验证日期、ip地址等,您应该使用不同的表来存储验证信息。但是如果你不打算使用任何数据,而是使用“verified”列,关于验证,同一个表中只能存储一列,
if you plan to store some other data, like verificationDate, ipAddress, etc. you should use a different table for verification information. But if you do not plan to use any data, but the "verified" column, about the verification, only one column can be stored in the same table,
当然,将临时数据与非临时数据分开存储要好得多。无需将该密钥存储在帐户表中。拥有一些 tblVerificationCodes,其中包含帐户表的 FK、时间戳等,并在可能的情况下从该表中删除(或存档,如果需要)数据。这是非常好的风格。
This is of course much better to store temporary data separate from nontemporary. There is no need to store that key in the account table. Have some tblVerificationCodes with FKs to the account table, timestamps etc etc and delete (or archieve if needed) data from this table when its possible. This is very good style.