简介模型关联问题 [英] Profile model association question

查看:142
本文介绍了简介模型关联问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是个好主意,作一简介自己的模式与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.

这篇关于简介模型关联问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆