Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:14:51+00:00 2026-06-18T14:14:51+00:00

I have 3 tables : -User -SuperUser -SpecialUser SpecialUser and SuperUser are extensions of

  • 0

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:14:52+00:00Added an answer on June 18, 2026 at 2:14 pm

    How I would do this is in pseudo-sql:

    Select * from user
    left outer join superuser
    left outer join specialuser
    

    And return everything. If superuser’s fields are not null, then in the PHP you can operate on that, same for specialuser. And this gives you two advantages:

    1) You don’t need a field to say what kind of user the user is anymore, the contents of the join will tell you.

    2) You can have a user be a superuser and a specialuser at once, if you wished. (And if you didn’t want that to happen, you can prevent it using a constraint or similar)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables user table user_id | name | 1 | peter |
I have two tables: user and asset and there is user_asset table that makes
I have these tables: USER TABLE uid | name | role | | 1
I have two tables user and email. One user can have multiple emails so
i have four tables user-question contains two columns: questionID, userID, the questions that the
I have three tables [USER] --Master user table [KEYWORD] --Master keyword table [USER_KEYWORD] --[USER]-[KEYWORD]
I have tables: user, comment and post, say: A user can have many posts
I have three tables: USER: user_id (pk); username FIELD: field_id (pk); name METADATA: metadata_id
I have two tables User id name Result id user_id score created_at Every hour
I have five tables: User user_id | name -------------------- 0 | Mark 1 |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.