I have 3 tables :
-User
-SuperUser
-SpecialUser
SpecialUser
and SuperUser
are extensions of the User
table. Let's say that User
table has {name
, email
}, SuperUser
has {idUser
, superPower
} and specialUser
has {idUser
, hairColor
}.
Of course a SpecialUser
and a SuperUser
have a name
and email
from the user table. This means that a User can be a SuperUser
or a SpecialUser
.
My question is how do I perform a query that gets all the info of a user (I don't know before the query if he is a specialUser or SuperUser).
I thought about 2 methods :
-Putting a column "userType" (0 : he is specialUser, 1 : he is superUser) in the user table
With this method, should I do a MySQL query with IF inside ? (What would be the query). Or should I do simple query (getting the user table alone) then in PHP I do a if and query the right table (super or special table)
OR
-Not putting any column and doing a MySQL query with 2 joins on the id of the user (technically one of the 2 joins won't return anything)
Which one should be used ? (I care about speed performance, less about memory - Let's say that the tables have over 1 million rows)