Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I create databases for subsites? [closed]

Tags:

php

mysql

drupal

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?

like image 589
user16948 Avatar asked Mar 16 '26 07:03

user16948


2 Answers

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 :)

like image 90
Not_a_Golfer Avatar answered Mar 18 '26 20:03

Not_a_Golfer


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:

  • 1234_settings
  • 1234_users
  • 5262_settings
  • 5262_users
like image 38
Pieter888 Avatar answered Mar 18 '26 22:03

Pieter888



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!