Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3597020
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:03:52+00:00 2026-05-18T20:03:52+00:00

Though my problem is specifically in Ruby on Rails, I’m also asking generally: I

  • 0

Though my problem is specifically in Ruby on Rails, I’m also asking generally: I have a users table and want to designate some users to be students and others to be teachers. What is the best way to design the schema in this case?

Edit:
Though I originally accepted vonconrad’s answer–it fits the original criteria–I have to reopen and adjust the question based on feedback from nhnb.

What should be done if students and/or teachers require additional (unique) attributes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:03:52+00:00Added an answer on May 18, 2026 at 8:03 pm

    This greatly depends on how many the different attributes between the teacher and student there’ll be as well as how often new unique attributes will be added or removed. If the case is that they will differ a lot, you have two choses:

    1. Make two models, one for Student and one for Teacher and use ruby include to share any logic between the two models. Any associations that associate with a user, you would use a polymorphic association (has_many :user, :polymorphic => true)
    2. Put the attributes in another table. For example: you’ll have the users table and a user_attributes table. users would have id, user_type, username, etc. and user_attributes would have id, user_id, attribute_name, value.

    If, however, your different attributes between the two users are few and pretty rock solid, you should just consider using Single Table Inheritance.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a seemingly simple problem though i am unable to get my head
I want to have the addthis widget available for my users, but I want
Specifically, I want to create a backup of a list, then make some changes
Problem: I relied heavily on NTFS Junction points in Windows XP, even though they
EDIT: I have managed to solve the problem by using: +lorem ipsum +type:photo +lorem
I'm running in to the same problem this individual has . Specifically, I'm trying
I recently ran into a problem that I thought boost::lambda or boost::phoenix could help
I'm trying to work through Project Euler and I'm hitting a barrier on problem
I'm currently looping through a datareader and calling the System.Net.Mail.SmtpClient's Send() method. The problem
I thought that it would be fun to present some classic CS problems and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.