多个表或多模式

Che*_*eng 5 postgresql database-design

Postgresql:使用每个具有 1 个模式的多个数据库更好,还是使用具有多个模式的 1 个数据库更好?

我是 PostgreSQL 模式概念的新手。

对于上述场景,我想知道

  1. 为什么我们不使用单个数据库(默认模式名为 public)
  2. 为什么我们没有一个表来存储多个用户行?
  3. 其他表保存用户相关信息,外键指向用户表。

谁能给我提供一个真实的案例场景,单数据库、多模式将非常有用,并且无法通过传统的单数据库、单模式来解决。

Kub*_*aun 4

来自http://www.postgresql.org/docs/8.4/interactive/ddl-schemas.html

人们可能想要使用模式的原因有多种:

*To allow many users to use one database without interfering with each other.
*To organize database objects into logical groups to make them more manageable.
*Third-party applications can be put into separate schemas so they do not collide with the names of other objects. 
Run Code Online (Sandbox Code Playgroud)

模式类似于操作系统级别的目录,但模式不能嵌套。