[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

mysql database structure question

Posted on 2012-09-12
1
Medium Priority
?
354 Views
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

thanks
0
Comment
Question by:prowebinteractiveinc
1 Comment
 
LVL 12

Accepted Solution

by:
Jared_S earned 2000 total points
ID: 38391422
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)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

591 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