I am designing a database for my application, I got issue in implementing the following logic.

A user may be a Vendor and also a Buyer. I have created a table for USER and created an another table called USERTYPE in that, the type had 'VENDOR' and 'BUYER' but I have to know if a user is both 'vendor' and 'buyer' by using a same email_id (User_id). Any idea or suggestion to implement this logic. Thanks in advance.

1 Answer 1


Yes, if a user can have many (e.g. up to 2) types, and each type of course has many users, then this is a many-to-many relationship.

Users >--------< UserTypes

Any logical many-to-many relationship needs a third physical table that references both.

Users ----< UserHasType >---- UserTypes

For example, this table could look like the following:

  user_id INT,
  type_id INT,
  PRIMARY KEY (user_id, type_id),
  FOREIGN KEY (user_id) REFERENCES Users(user_id),
  FOREIGN KEY (type_id) REFERENCES UserTypes(type_id)
  • thanks for your answer, I do understood this idea, but till now, I don't know how to implement many to many relationship, I hope now I can do this. Commented Oct 29, 2013 at 4:55

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.