views:

151

answers:

1

Consider web (MVC, for example Rails) application for multiple clients as a service.

How to design this?

  • one application instance per client? (+ one database per client)

  • one instance for all clients (+ one database for all clients)

Former one is simple, but... "inefficient". How about the latter? (best practices, design patterns) How to separate client data? For example: worker "A" of client "1" has two documents, worker "B" of client "2" has three documents. How to build model associations to protect other users (and clients) data? I think joining every query with Client model is not a good solution.

A: 

I would suggest having a look at an earlier response on multi-tenant apps in Ruby on Rails.

It really depends on your use case, but the simplest way to handle this is a single database with scoping to particular applications. You can head from there depending on your requirements/budget.

I am a big fan of the postgresql schema system detailed in that link :P

Toby Hede