为每个商家分配在线库存系统的数据库是否合适? [关闭]

为每个商家分配在线库存系统的数据库是否合适?  [关闭]

问题描述:

For example, Company Abc will have it's own database: Database_Abc.

Let's say each Database will consist of the following tables:

  1. staffs
  2. products
  3. inventory
  4. logs

or

one centralized database with unique merchant id would be better?

  1. staffs - merchant_id
  2. products - merchant_id
  3. inventory - merchant_id
  4. logs - merchant_id

which method is good for scalability?

例如,公司Abc将拥有自己的数据库:Database_Abc。 p>

假设每个数据库都包含以下表格: p>

  1. 人员 li>
  2. 产品 li>
  3. 库存 li>
  4. 日志 li> ol>

    或 p>

    一个具有唯一商家ID的集中式数据库会更好吗? p>

    1. 员工 - merchant_id li>
    2. 产品 - merchant_id li>
    3. 库存 - merchant_id li>
    4. logs - merchant_id li> ol>

      哪种方法有利于扩展? p> div>

Well, it's not just a question about database management but also a server-side applications thoughts.

  1. Starting from a scratch one centralized DB with uniform server-side application will do the trick nicely and in case of horizontal increase of data will scale almost perfectly

  2. If you have various and very different requests per each company you'll need to think about implementation for each company with it's own design. Such approach consumes more resources but will fit individual customers

Speaking of database management you'll need to ask yourself following questions

  1. What type of data will be stored? You should keep in mind that storing financial data best fits for DECIMAL type for example.
  2. Think about relations between tables - thus think about correct FOREIGN KEYs for example.
  3. Think about possible shortcomings of MySQL itself - for example, it's not suited well for full-text search
  4. How your data will increase in size? If it will increase very rapidly, you will need to think about PARTITIONING for example
  5. Think about replication and backup issues.
  6. Where will you host your database? You can think about cloud services thus not thinking about administration etc.

I reccomand you to centralize the database with unique merchant id because is more efficiently for you and for computer (mysql, php, etc.) to manage the database.