简体   繁体   中英

HOW TO Create new databases or database instances on the application for each user?

As you know when you have an application like a blog, users can post articles, galleries, create static pages, editors edit them...

You have tables like:

  • Articles
  • Authors
  • Editors
  • Galleries
  • Static Pages etc.

What if you want to create a blog service that every user can create their own blogs?

When we look again to the example above, we have to create some additional tables and fields on each table.

Some user can subscribe our service, and create their blog:

Subscriber Blogs subscriber_id Authors blog_id Editors blog_id Galleries blog_id Static Pages blog_id

And you have to check on every request that if the user has that blog, is authorized etc. etc.

As you see this is extremely complicating a simple blog software.

Instead of this, is there any app or cloud service that I can use it's api on my software and create a new fresh clean database instance with the apps sql and when my users register and start to use their service?

I am very stuck on this now... Any help will be appreciated.

I'm a little confused.

  1. You want to have a blog service where people can sign up and get there own blog site?
  2. You want to put each new blog user on a separate database?

Unless you are planning on having hundreds of thousands of users You really just need 1 database to start.

I don't think you'll need to create extra tables or fields. All your tables that link to the author should already have an author_id field or a joining table.

So.. The bloggers, when registering, will be put into authors.

Authors will contain there ID.

All other tables will relate to that id either through an id field or joining table. So if you selected from articles, galleries, ect... you would simply do

SELECT * FROM articles WHERE author_id=1234

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM