I want to have a website that lets users create their own websites. Something like wordpress.com or drupalgardens.com .
My question is how should I create databases for users` websites? Should I create a seperate database for each user? Should I create a few databases and use different table prefixes for each user?
Does having thousands of databases cause performance problem?
Create a database per user, it will make permission problems and namespacing bugs less likely, and will make you use mysql's permissions system like it was designed to. AFAIK this is how most shared hosting systems work.
If it wasn't for the overhead, I'd create a separate MySQL instance for each user, but then you're half way to virtualizing the whole system, and making it into a VPS :)
If you don't mind a having a lot of tables, and are not worried for your users permissions: You can have one "master_table" which contains each website and it's unique id. Based on that id you can create table prefixes like:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With