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?
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:
has_many :user, :polymorphic => true)userstable and auser_attributestable.userswould haveid, user_type, username, etc.anduser_attributeswould haveid, 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!