How to store various user information in a database?

My first post :)

I just started learning Rails and am having some doubts about database modeling. I create a site for one football club and have many different types of users. Each user can go to the site and have their own control panel. They also want each user to have a separate part on the site for registration. So, on my site I will have the links "Register as a player" and "Register as a coach."

These will be my users on the site and their attributes:

SuperAdmin (id, username, firstName, lastName, password)

Admin (id, username, firstName, lastName, password, is_enabled)

Coach (id, username, firstName, lastName, password, is_enabled, coachRole, salary, contractStarted, contractEnds, vacationDaysLeft)

Player (id, username, firstName, lastName, password, is_enables, salary, contactStarted, contractEnds, birthDate, height, weight, goals, assists, minutesPlayed, gamesPlayed)

What will be my options here?

OPTION 1

I was thinking of doing something like this:

create_table "users", force: true do |t|
    t.string   "username"
    t.string   "userRole"
    t.boolean  "is_enabled"
    t.string   "firstName"
    t.string   "lastName"
    t.string   "password"
    t.string   "coachRole"
    t.integer  "salary"
    t.datetime "contractStarted"
    t.datetime "contractEnds"
    t.integer  "vacationDaysLeft"
    t.datetime "birthDate"
    t.integer  "height"
    t.integer  "weight"
    t.integer  "goals"
    t.integer  "assists"
    t.integer  "minutesPlayed"
    t.integer  "gamesPlayed"
    t.datetime "created_at"
    t.datetime "updated_at"
end

userRole SuperAdmin, Admin, Coach, Player. . , null.

, Coach, :

[ " ", "", "is_enabled", "firstName", "lastName", "password", "coachRole", "", "contractStarted", "contractEnds", "vacationDaysLeft" ", null, null, null, null, null, null, null," created_at "," updated_at "]

Admin, :

Admin [ "username", "Admin", "is_enabled", "firstName", "lastName", "password", null, null, null, null, null, null, null, null, null, null, null, null, "created_at", "updated_at" ]

, .

2

-, , "" User, :

create_table "users", force: true do |t|
    t.string   "username"
    t.string   "userRole"
    t.boolean  "is_enabled"
    t.string   "firstName"
    t.string   "lastName"
    t.string   "password"
    t.string   "type"
end

:

class SuperAdmin < User
end

class Admin < User
end

class Coach < User
end

class Player < User
end

, , . , . . , .

, . .

+3
1

"". "". "", "". , "coachRole", "" , , , ( ).

:

class User < ActiveRecord::Base 
  has_many :properties
end

class Porperty < ActiveRecord::Base 
  belongs_to :user
end
+2

All Articles