REST API / DATA MODEL DESIGN - User , Account or B

2019-07-02 00:43发布

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.

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.

Thanks in advance for you help

Cheers

1条回答
Emotional °昔
2楼-- · 2019-07-02 01:22

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.

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.

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.

查看更多
登录 后发表回答