I m writing an application that that I m going to provide as a service and also as a standalone application. It s written in Zend Framework and uses MySQL.
When providing it as a service I want users to register on my site and have subdomains like customer1.mysite.com, customer2.mysite.com.
I want to have everything in one database, not creating new database for each user.
But now I wonder how to do it better. I came up with two solutions: 1. Have user id in each table and just add it to WHERE clause on each database request. 2. Recreate tables with unique prefix like customer1_tablename , customer2_tablename .
Which approach is better? Pros and cons? Is there another way to separate users on the same database?
Leonti