I'm working on a project management app, where every company (which uses our app) will have a personal subdomain: company.domain.com. For many reasons I decided to use a separate database for each company.
Companies can invite people (by email) to work together on projects. A user can belong to multiple companies (so should appear in multiple databases). However, user data, and login information are stored in a seperate db because users use the same username, password for each company, and their first name, and last name is the same for each company.
What I do now, is the following:
- there exists a separate database with: users, identities (user_id, username, password).
- there also exists a users table in every database of each company, containing the same data about the user (actually only 3 fields: first name, last name, time zone).
Is there a better solution for this? If you have questions about the question :) please ask.
I'm using php + mysql.