Hey Guys, Wondering if anyone can help me with this little chesnut?? I am developing an app that has two different user types, lets say, student and teacher. A teacher or a student can both create "a group" and a regular user can then search through all of these groups together. So there is no real difference between the two as far as a regular user can see. Is it best practise to separate this into two tables so I would have a student_group table and a teacher_group table? My question is how do you group the two together so the two can be displayed in search results? Cheers Stuart
Create a table called group_owner ( or person or staff or group_users or something ), then make the function, teacher or student, an attribute of the person. So you get at least a field with "Function", let's say you have: name, function, groupname, etc... Later you can select based on the attribute like: SELECT groupname FROM group_owner WHERE function = "Teacher";
or not: SELECT groupname FROM group_owner; or just student owners: SELECT groupname FROM group_owner WHERE function = "Student"; Note the field "Function" in this case could also be a boolean as there are only 2 options, so you could have true = teacher and false = student alternatively use an ENUM if there are possibly more roles.