Should I use a single or multiple database setup for a multi-client application?

前端 未结 10 733
囚心锁ツ
囚心锁ツ 2020-11-30 17:50

I am working on a PHP application that intends to ease company workflow and project management, let\'s say something like Basecamp and GoPlan.

I am not sure on what

10条回答
  •  醉梦人生
    2020-11-30 18:14

    When you're designing a multi-tenant database, you generally have three options:

    1. Have one database per tenant
    2. Have one schema per tenant
    3. Have all tenants share the same table(s)

    The option you pick has implications on scalability, extensibility and isolation. These implications have been widely discussed across different StackOverflow questions and database articles.

    In practice, each of the three design options -with enough effort- can address questions around scale, data that varies across tenants, and isolation. The decision depends on the primary dimension you’re building for. The summary:

    • If you're building for scale: Have all tenants share the same table(s)
    • If you're building for isolation: Create one database per tenant

    For example, Google and Salesforce follow the first pattern and have their tenants share the same tables. Stackoverflow on the other hand follows the second pattern and keeps one database per tenant. The second approach is also more commonplace in regulated industries, such as healthcare.

    The decision comes down to the primary dimension you're optimizing your database design for. This article on designing your SaaS database for scale talks about the trade-offs and provides a summary in the context of PostgreSQL.

提交回复
热议问题