Let's say you have students
and you have teachers
Students log in to the site using a different interface than teachers
Students can do the following on the site - Look up grades - Email teachers
Teachers can do the following on the site - Lookup up students - Input grades
How would you design the database table to allow teachers and students to log in? This question confuses me because I was thinking of doing the following
- of having a teacher table
- of having a student table
two separate tables
so
create table teacher ( name varchar(255), email varchar(100), password varchar(100) )
create table student ( name varchar(255), email varchar(100), password varchar(100) )
Is that how it is usually done? When you have two different entities logging in to two different login interfaces?
--- EDIT ---
also what if the two entities have different fields? Would you still create one Users table with a "Role" in that case.
For example, what if you have the following:
(notice how teacher and student have a few fields different. Would you still create one table to put them both??)
create table teacher ( name varchar(255), email varchar(100), password varchar(100) num_of_students int,
)
create table student ( name varchar(255), email varchar(100), password varchar(100), gpa decimal(10,2) )
create table user ( name varchar(255), email varchar(100), password varchar(100), role varchar(45))- Jorge GuberteUsertable. I would have aUser,RoleandUser_Roletable. There is a N:M relationship betweenUserandRoleentity. This is what you basically have in every app with role-based security. - Fabian Barney