title: CakePhp Multiple tenants - single DB versus multiple DBs
body: <p>We are working on an application in CakePHP that will be used by multiple companies. We want to ensure performance, scalability, code manageability and security for our application.</p>
  
  <p>Our current beta version creates a new database for each customer. When a new company joins the site we run a SQL  script to create a blank database.
  This has the following advantages:
   - Better security (companies users are separated from each other) 
   - We can set the database via the subdomain (IE: monkey.site.com, uses the site_monkey database)
   - Single code base.
   - Performance for SQL queries is generally quite good as data is split across smaller databases. </p>
  
  <p>Now unfortunately this has many disadvantages
   - Manageability: changes to database have to happen across all existing databases
   - The SQL script method of creation is clunky and not as reliable as we would like
   - We want to allow users to login from the home page (EG. www.site.com) but we cant currently do this as the subdomain determines what database to use.
   - We would like a central place to keep metrics/customer usage. </p>
  
  <p>So we are torn/undecided as to what is the best solution to our database structure for our application. </p>
  
  <p>Currently we see three options:
   - Keep multiple database design
   - Merge all companies into one DB and identify each by a 'companyId'
   - Some kind of split model, where certain tables are in a 'core database' and others are in a customer specific database.</p>
  
  <p>Can you guys offer some of your precious advise  on how you think we should best do this?
  Any feedback / info would be greatly appreciated.</p>
  
  <p>Many thanks,</p>
  
  <p>kSeudo </p>