多用户Web应用数据库设计 [英] Multi-user Web Application Database Design

查看:383
本文介绍了多用户Web应用数据库设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Web应用程序,完成后将成为托管的多用户解决方案。我试图找出处理我的应用程序的数据库设计的最佳方法。具体来说,我需要弄清楚如何处理多个单独的帐户。

I'm working on a web application that will be a hosted, multi-user solution when it is finished. I'm trying to figure out the best way to handle the database design for my app. Specifically, I need to figure out how to handle multiple, separate accounts.

我看到的方式有几个选项:
1)有一个一组数据库表。在每个表中,包括一个用户列或类似的,将每行映射到正确的用户帐户。
2)为每个用户创建一个完全独立的数据库。由于性能原因,这似乎不是一个非常棒的主意。
3)为单个数据库中的每个用户创建单独的模式。每个模式将包含每个用户的表。

The way I see it, there are a few options: 1) Have one set of database tables. In each table, include a 'user' column or something similar which will map each row to the proper user account. 2) Create a totally separate database for each user. This doesn't seem like a terribly great idea for performance reasons. 3) Create a separate schema for each user within a single database. Each schema will contain the tables for each user.

您将如何处理此问题?有没有选择我失踪了?我使用PostgreSQL作为我的数据库,如果这样做会有什么不同。

How would you handle this problem? Is there an option I'm missing? I'm using PostgreSQL as my database if that makes any difference in how you would handle this problem.

推荐答案

总是随着选项#1而消失。如果您正确设计,您可能只需要在几个关键表中的用户列,这是您的入口点,然后可以从这些关键表中加入其他所有内容。

I've almost always gone with option #1. If you design it right you may only need your 'user' column in a few key tables that are your entry point and then everything else can be joined off of those key tables.

这篇关于多用户Web应用数据库设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆