Rails: One model for Authentication and Profile information or 2 separate models

authentication, model, profile, ruby-on-rails

Solution

If you want to follow database normalisations you should separate the tables. However, sometimes it is not the best option... For example, if your table `users` has just `email`, `password` (for authentication) and `name`. I won't create a `profile` table just to store the `name`, right?

So, it will depend on your requirements to make your design decisions....

I found this interesting post about it, where @D Roddis explain some advantages and disadvantages about three different approaches: `Storing User Profile in Users Table`, `Storing User Profile in User_Profile Table 1-1 relationship to users` and `Storing User Profile as properties and values in tables`.

I hope it helps...

Problem

In many tutorials (especially for authentication), speakers say to put user authentication and profile information in the same table (model) called User. My question is simple: Is it safe to put everything in one table? (bonus: is this the best practice?) I would rather suggest to separate authentication information (email, password, salt,...) and profile information (first name, last name, birth day, location, gender,...) in two models: User (for authentication) and Profile, and linking models by has_one/belongs_to associations. Am I wrong? What do you suggest me? Thanks.

Original source

Related problems