制定实施方案。 Admin 作为单独的表或列

发布于 2024-12-27 13:34:02 字数 163 浏览 5 评论 0原文

可能我的问题是理论上的,但我想知道您对 devise 作为单独的表或用户表中的列的用法有何看法。

一些基本点很值得讨论: 1. 在什么情况下您会选择这个或其他实现? 2. devise在实现为单独的表时添加了哪些方法? 3. 您认为实施该设计最简单的方法是什么?为什么?

先感谢您

May be my question is to theoretical, but I would like to know your opinion on what is the usage of devise as a separate table, or a column in a Users table.

Some basic point would be great to discuss:
1. In what situation would you choose this or the other implementation?
2. What methods does devise add when implementing it as a seperate table?
3. What do you find the easiest way to implement devise, and why?

Thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故人爱我别走 2025-01-03 13:34:02

当然,您可以在每个应用程序中创建 2 个或更多设计模型。

但在许多情况下'单表继承(STI)'可能对你有很大帮助。
如果数据没有不同并且具有相同的行为,则很好。
它将使您有时能够轻松处理复杂的数据

但是当每个角色存储不同的数据时,表中会创建大量空列,并且查询时间较慢

如果您想自定义角色可以执行的更多操作,那么您可以使用 Cancan 它将帮助您的生活更轻松。

PS。在现实生活中,规范化的数据并不意味着它有良好的数据库设计。

Sure you can do 2 or more devise model in each application.

But in many case 'Single Table Inheritance(STI)' might help you a lot.
Is good if data is not different and have a same behavior.
It will make you easy to handle complex data sometimes.

But there is create a lot of null column in table when each role is store different data and it have a slower query time.

If you want to customize much more what is role can do then you Devise with Cancan it will help you life easier.

PS. In real life normalized data is not mean it have a good database design.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文