Skip to content
Advertisement

Single table or multiples tables (multiple company database)

I have to create a database for multiple companies, I have 2 options

  1. A single products table, with a company_id field to differentiate

  2. One table per company

    products_company1
    products_company2
    products_company3

Important:

  • Data stored of each client will be updated every 1 hour
  • Each company has 2000 – 3000 records, and 15 company will be stored approx.
  • Products table is an example, each company has more tables.

I did a search, but did not find information about multiple tables, only multiple databases (I don’t think multiple databases its a good option for me)

Advertisement

Answer

You want option 1 under almost all circumstances. Here are some reasons:

  1. Relational databases are optimized to work on large tables, not on large numbers of tables.
  2. Maintaining foreign key relationships is very challenging.
  3. Maintenance many tables (say by adding a column or changing a data type) is a nightmare compared to maintaining one table.
  4. Answering a simple question such as “how many companies have product X” is a nightmare.

There are no doubt other reasons as well. These come to mind.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement