Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 933799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:53:32+00:00 2026-05-15T20:53:32+00:00

i want my database to support one company haveing many users how can i

  • 0

i want my database to support one company haveing many users how can i do that?
example

users table(UID,username,password)
company table(CID,companyname,usersthatistheownerofthecompany)

how can i do that? what should i do ? should i make an array in php like 1241,423,4123 *uid’s that will be inserted on usersthatistheownerofthecompany row ? or is there any better idea ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:53:32+00:00Added an answer on May 15, 2026 at 8:53 pm

    If you want each user to have one (and never more) company, you should have :

    • user table
      • uid
      • username
      • …
      • company_id
    • company table
      • company_id
      • company_name
      • …

    Then, user.company_id would be a foreign key, that references company.company_id.

    And, then, you store :

    • One line in user for each user
      • Referencing the id of the right company for that user
      • which is the company_id of the right line in the company table.
    • And one line for each company in company

    There is no user’s related information stored in the company table — and as each user “points” to a company, a company can have several users.

    Storing data as an array like you suggested is definitely not quite a good idea — just not the way a relational database works.

    If each user can have several companies, and each comparny can have several users, you’ll have to add a third table (a join table), that will indicate, for each user(s), to which company(ies) they are attached to :

    • user table
      • uid
      • username
      • …
    • company table
      • company_id
      • company_name
      • …
    • user_company table
      • uid
      • company_id

    In this situation, there is no user-related stuff in the company table, and there is no company-related stuff in the user table : the link between those is in the user_company table.

    Of course, user_company.uid will be a foreign-key to user.uid ; and user_company.company_id will be a foreign-key to company.company_id.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is a good database with support for C? I want a database that
I want to made one application that use a database of 400Mb in sqlite3.
There is an existing table in database where I want to update one column.
I have a table in Oracle 11.2 database. I want the database to run
I want to add database elements into array. how do I do that. the
I am want to export database table to a file. I am using the
I want my database to support multi Languages for all text values in its
I have some code that uses an Informix 11.5 database that I want to
Well I want your opinions about this case: I need a database that will
This is a is it possible question. I have one database file that contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.