Mysql – User Table Design

database-designMySQL

I am designing for an ecommerce application. I need to know how to implement the following task.

There are 2 options,

  1. Unregistered Users (Free Listing).
  2. Registered Users.

The unregistered users will give all their data but they are not registered with our site.

The registered users will give data and become a partner with our site.

I have designed the table to store the data for both user types on a single user registration table. Now I need to separate both these users, so that I can handle them separately. How to do this?

I am expecting some kind of reference / books on enterprise level database design strategies, so that I can learn and understand.

Thanks in advance.

Best Answer

Make a generic table call Users with a unique ID by line (user_id)and put your generic infos (email, password...), used for both Registered and Unregistered users.

Next, create a table "Registered_Users" to store specific info, with a column user_id (which point to Users table : foreign key).

If you want to query just global info about all your users, query :

SELECT ...
FROM Users u

If you want to query your specific info about registered users, query:

SELECT ...
FROM Users u
JOIN Registered_Users re
ON (u.user_id = re.user_id);

Max.