On a PHP/MySQL application…
We are planning to offer users the ability to create simple DataBases.
Let say it can get up to more than 10000 main user accounts and maybe several times more after some years.
What would be the efficient way to go?
A) Create the user defined tables and fields directly into our Application´s DB ?
Wouldn’t that be like… our ~40 tables app´s AND like 10000 user created tables?
I understand that at the moment of querying and usage etc it will be efficient
B) Having tables of tables and fields?
like…
- table usrtables
- tabID
- usrID
-
tabName
etc.
-
table usrfields
-tabID
-fldName
-fldType
-fldContent
etc.
thank you very much
If you want to be a hosted database provider a good idea is to actually give each user their own databases containing their tables, this will be the best for security and scalability.
Option 1 running all the user in your single database will result in some issues because you will have a lot of tables, but at least you will still be able to scale because as long as each user’s tables are not “talking” to each other (joins), you can shard/partition by user to multiple hosts. You end up with almost the same structure and amount of work as giving everyone their own database in the first place. If you have to do joins across user once in a while this might be a better way.
Option 2 will cause all users data to mingle togather into huge tables, this will start to cause issue very soon with index write overheads, horizontal partitioning, and lock contention. The way to scalability is to try to break down data to small isolated chunks where possible, this approach is heading to the exact opposite direction.