mysql database structure question

Posted on 2012-09-12
Last Modified: 2012-09-16
I have 2 tables companies and users, what is the best way to set the structure when many companies can have many users & many users can have many companies

Question by:prowebinteractiveinc
    1 Comment
    LVL 12

    Accepted Solution

    I would think adding another table will make updates and maintenance a little easier.

    Table 1: Company (ID, CompanyName)
    Table 2: Users (ID, UserName)
    Table 3: Affiliation (ID, UserID, CompanyID)

    Company and Users will both have a one to many relationship with Affiliation.

    Otherwise, denormalize the Users table.

    Table 1: Company (ID, CompanyName)
    Table 2: Users (ID, UserName, CompanyID)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
    Creating and Managing Databases with phpMyAdmin in cPanel.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now