I am creating a sample web application for a business and I am stuck at the login implementation. There is supposed to be two different users (login types?). I will have employees and customers. I have a table for employees and a table for customers set up already. Let me caveat that I understand the following is not SQL, just the notes I've taken so far in a .txt file.

I have my employees

    Employee_ID  CHAR(5) - 'EM###' - NOT NULL //PK
    ...(columns unimportant to the scope of this question) 

I have my customers

    Customer_ID //PK
    ...(more columns)

And here is where I get stuck at the web login


I've read other methods to create a table for login information and they referenced a LEFT JOIN in SQL, but that seems like it would only be good if I was referencing 1 other table and not two different tables. How can I pull EMPLOYEE information if the Login ID entered is from the EMPLOYEE tables and vice versa for customers?

2 Answers 2


First of all, every thing depends on business logic you have. If employees and customers it's fine to use 2 diferrent tables, to connect them with the table WEB_USER_LOGIN I would just append and field like 'usertype'.

If your database is Oracle you can have object tables to solve this problem, if its PostgreSQL you can hava inherited tables.

If its mysql I would use just one table with both fields, but if you prefer to use the left join it's ok but I would create a VIEW for it.

  • I went with a similar idea but slightly different Commented Oct 12, 2012 at 0:12

I made the login table independent of customer and employees. The login table holds a foreign key to a categories table that will hold types of user logins (either customer or employee for now). By keeping it separate, it won't be a requirement for any person to have a web access account. Business rules can dictate if the employee requires an account, it can be created with their initial addition into the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.