Suppose I have a website that communicates with a database.
In some page of my site i want to exhibit a list with all the students in my database. There are two kinds of students: regular students, that only participate in regular classes (with attributes such as
student_id, name, email, password) and special class students, students who participate not only in regular class but also in special extra classes (with all the attributes the regular students have plus an attribute for the
In the exhibition of the students on the mentioned page, I want it to exhibit the student differently depending on whether it's a special class student or not.
So i'm thinking here what would be the best database design in order for the code for the exhibition of the students to have the best efficiency/performance.
Two tables on my database, one for all students (with
student_id,name,email,password) and one extra for special class students (with
student_id and a
special_class_id corresponding to the id of the special class the student participates). Let's name the table with all students by
students and the other one by
With this option, for the exhibition page, the code would pick each row of the
students table and display it. It could then check whether that
student_id was inside any row of the
special_students table, and if it was, it could exhibit that student differently.
Another option would be having only one table on my database with an extra
special_class_id column. Then, for regular students this column would have some default value (maybe
0), and for special class students, this column would have value identifying the
With this option for the exhibition page, it seems to me that the code would be faster since it would query only one table .. but on the other hand, adding this extra column seems a bit sloppy.
Would there be a significant performance advantage on the second option, over the first one, considering an hypothetical situation where the site might have 10 million visitors a day? Can this sloppy extra-column interfere in some way and cause problems? Is there any other option for the database design?
Thanks a bunch in advance.