REST API /数据模型设计 - 用户,帐户,或这两种模式? [英] REST API / DATA MODEL DESIGN - User , Account or Both Models?

查看:107
本文介绍了REST API /数据模型设计 - 用户,帐户,或这两种模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于适当的一些想法构建我的应用程序,并为其提供一个良好的和一致的API,但现在我有关于用户的一些疑惑/账户模式。

I'm having some thoughts about proper building my app and provide a good and consistent API for it but now I'm having some doubts about the user/accounts model.

这很有趣,但如果你考虑一些应用程序,你会看到,他们把你喜欢的用户,但编辑您的详细信息,当你被重定向到帐户。

It's funny but if you consider some apps you will see that they treat you like user but when editing your details your are redirect to account.

这方面的一个很好的例子是Twitter的。

One good example of this is twitter.

所以,我想知道你对什么是建立这种体系结构的最佳方法意见?

So I would like to know your opinion about what's the best method to build this kind of architecture?

时的帐号真的有必要吗?

Is the account really necessary?

我为什么要使用帐户或用户?

Why should I use account or user?

如果我决定以后实施该用户的支付指令,应该用户存储中存储了密码和其他重要信息,帐户里面的信息?

If I decide to implement a payment instruction for that user later, should that user store that information inside a account which stores his password and other important information?

抱歉,但我有点失去了在这个问题上,有时它看起来是其他应用程序使用更多的模型比必要的,所以我不知道:(

sorry but I'm kind of lost on this subject sometimes it looks that other apps use more models than the necessary, so I'm not sure :(

我在想,我已经给相关的模型是这样的:

I was thinking I'm have to associated models like this:

 User has_one :account

但我还是不知道去什么样的信息到用户和帐户。

But I still not sure what kind of information goes into the User and Account.

在此先感谢您的帮助。

干杯

推荐答案

这真的取决于应用程序。看电话的例子。一个家庭或公司可能有一个或多个电话帐单在一起,这样的电话号码是不相同的帐号。

It really depends on the application. Look at telephones for example. One household or company may have one or more telephones billed together, so telephone number is not the same as account number.

对于许多Web应用程序,有一个帐户为一个用户,反之亦然。我可以开多个账户,一个作为标记的计算机的家伙,一个作为马克钢琴家等。因此,用户是不是一个真正的人,但更像是一个角色,或字符我玩。如果我的音乐生涯真正起飞我可能会雇一个人P.R.来管理我的标记的钢琴家科目。在这种情况下,应用程序可以配合用户和账号起来:一个帐户为每一个角色。这是很好的一个免费的应用程序。

For many web applications, there is one account for one user and vice versa. I can open several accounts, one as "Mark the computer guy", one as "Mark the pianist" and so on. So a user is not a real person but more like a persona, or a character I play. If my music career really takes off I might hire a P.R. person to manage my "Mark the pianist" account. In this case the application could tie "user" and "account" together: one account for each "persona". This is good for a free app.

对于不同的例子,看看要花钱的Web托管服务。我可以创建一个帐户,然后建立了几个用户谁可以登录:我,我的Web开发人员,我的系统管理员等,所以有一个帐户多个用户

For a different example, look at a web hosting service that costs money. I might create one account and then set up several users who can log on: me, my web developer, my systems administrator, etc. So there's one account for several users.

这篇关于REST API /数据模型设计 - 用户,帐户,或这两种模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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