简介模型关联问题

编程入门 行业动态 更新时间:2024-10-28 10:26:39
本文介绍了简介模型关联问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是个好主意,作一简介自己的模式与HAS_ONE / belongs_to的与用户模型关联,还是应该配置文件的属性只是在用户数据库列?

Is it a good idea to make a profile its own model with a has_one/belongs_to association with the User model, or should the attributes of a profile just be columns in the user database?

推荐答案

这是真的,需要由它怎样被使用来决定一个设计决策。

This is really a design decision that needs to be decided by how its going to be used.

我最近创建一个具有用户和轮廓模式与用户分离总是具有程序的个人资料的约束。

I've recently created a program that has a 'user' and 'profile' model separated with the 'user' always having the a 'profile' constraint.

我就是这么做的,因为没有什么在用户表中的其他然后登录用户或允许管理员看到/做某些事情所需的信息。

I did it this way since there is nothing in the 'user' table other then information needed to login a user or allow the admin to see/do certain things.

鉴于个人资料模式包含一个可查看和其他成员检索数据。

Whereas the 'profile' model contains data that can be viewed and searched on by other members.

但同样,它的你有一个设计决策基于数据将被如何使用做。

But again, its a design decision you have to make based on how the data will be used.

更多推荐

简介模型关联问题

本文发布于:2023-10-28 22:38:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537975.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模型   简介

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!