简体   繁体   English

如何在每个用户的应用程序上创建新的数据库或数据库实例?

[英]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 订阅者博客subscriber_id作者blog_id编辑者blog_id画廊blog_id静态页面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? 而不是这个,是否有任何应用程序或云服务,我可以在我的软件上使用它api并使用应用程序sql创建一个新的干净数据库实例,当我的用户注册并开始使用他们的服务?

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. 链接到作者的所有表都应该已经有author_id字段或连接表。

So.. The bloggers, when registering, will be put into authors. 所以..博主们在注册时会被写入作者。

Authors will contain there ID. 作者将包含ID。

All other tables will relate to that id either through an id field or joining table. 所有其他表将通过id字段或连接表与该id相关。 So if you selected from articles, galleries, ect... you would simply do 所以,如果你从文章,画廊等中选择...你就可以做到

SELECT * FROM articles WHERE author_id=1234 SELECT * FROM articles WHERE author_id = 1234

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在php中为每个新用户创建数据库和表? - How to create database and tables for each new user in php? 如何使用MySQLi准备的语句创建新的MySQL数据库用户? - How to create new MySQL database user with MySQLi prepared statements? 如何从 php 创建一个新的 mySQL 数据库用户 - How to create a new mySQL database user from php 如何创建2个PDO数据库连接实例PHP - How to create 2 PDO database connection instances PHP 如何处理用户对可以访问多个数据库的应用程序的访问 - How to handle user access to an application that can access multiple databases 为每个经过身份验证的新用户创建新的 Firebase 数据库存储 - Create New Firebase Database storage for each new authenticated users 如何使用Laravel 7为mysql中创建的数据库创建新的数据库和用户? - How to Create new database and user only for the created database in mysql using Laravel 7? 如何在 Laravel 中创建新用户? - How to create new user in Laravel? 如何为数据库中的每个活动用户创建一个具有嵌套表单的Symfony表单? - How to create a Symfony form that has a nested form for each active user in the database? 如何创建集中式用户数据库 - How to create a centralized user database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM