帮助设计 web-cms 数据库
我在为网络 CMS 设计数据库时遇到问题,我有一个“用户”表来保存用户及其帐户信息。安排已删除的用户帐户的最佳方式是什么。 第一种方式,我可以创建一个“DeletedUsers”表并保留帐户已被删除或删除的用户信息。 在第二种方式中,我将向用户表添加一个名为“AccountProperty”的新列,该列只接受两个值:“Active”和“Inactive”。了解哪些帐户仍然活跃,哪些帐户不活跃或已删除。 还有更好的办法吗?
I have a question in designing a database for a web-CMS, I have a “Users” table to keep the user and their account information.What is the best way to arrange the user accounts which are removed.
In first way, I can create a “DeletedUsers” table and keep the users information whose account has been removed or deleted.
In second way ,I will just add a new column to the User table named “AccountProperty” which ony accept two values: “Active” and “Inactive”. To understand which accounts are still active and which are inactive or removed.
Is there any better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第二个选项显然是两个选项中最好的一个,尽管我个人会将其定义为布尔值而不是枚举(看起来 AccountProperty 是一个枚举)。
在我看来,创建一个额外的表是解决以后潜在问题的好方法。 (可能是应用程序中的某些错误或其他情况将用户添加到DeletedUsers,但没有将其从用户中删除,仅举一例)。将 Active 属性设置为“false”似乎更清晰。
Your second option is clearly the best of the two, although personally I would define it as a boolean instead of an enum (it looks like AccountProperty is an enum).
Creating an additional table looks to me like a good way to open up for potential problems later on. (Could be that some bug in your application, or other circumstances add the user to DeletedUsers, but doesn't remove it from Users, just to name one). Setting the Active property to "false" seems cleaner.