模式和目录是什么意思? [英] What do schema and catalog mean?

查看:112
本文介绍了模式和目录是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Silberschatz等人的《数据库系统概念》:

From Database System Concepts, by Silberschatz et al:


4.5.7模式,目录和环境

4.5.7 Schemas, Catalogs, and Environments

。用户必须协调以确保他们确实
不会尝试将相同的名称用于不同的关系。当代的
数据库系统提供命名关系的三级层次结构
层次结构的顶层由目录组成,每个目录可以
包含方案。 SQL对象(如关系和视图)包含在架构中的
中。 (某些数据库实现使用术语
数据库 代替术语目录。)

Like early file systems, early database systems also had a single name space for all relations. Users had to coordinate to make sure they did not try to use the same name for different relations. Contemporary database systems provide a three-level hierarchy for naming relations. The top level of the hierarchy consists of catalogs, each of which can contain schemas. SQL objects such as relations and views are contained within a schema. (Some database implementations use the term "database" in place of the term catalog.)

为了对数据库执行任何操作,用户(或程序)
必须首先连接到数据库。用户必须提供用户名
,通常还需要提供用于验证用户身份的密码。每个
用户都有一个默认目录模式,并且该组合对于该用户而言是唯一的
。当用户连接到数据库系统时,将为连接设置默认的
目录和模式。这对应于
用户登录到操作系统时当前目录设置为用户主目录的

In order to perform any actions on a database, a user (or a program) must first connect to the database. The user must provide the user name and usually, a password for verifying the identity of the user. Each user has a default catalog and schema, and the combination is unique to the user. When a user connects to a database system, the default catalog and schema are set up for the connection; this corresponds to the current directory being set to the user’s home directory when the user logs into an operating system.

唯一标识关系,可以使用三部分名称,例如
,catalog5.univ schema.course我们可以省略目录
组件,在这种情况下,名称的目录部分被视为
是连接的默认目录。因此,如果catalog5是
的默认目录,我们可以使用univ schema.course唯一地标识相同的
关系。

To identify a relation uniquely, a three-part name may be used, for example, catalog5.univ schema.course We may omit the catalog component, in which case the catalog part of the name is considered to be the default catalog for the connection. Thus if catalog5 is the default catalog, we can use univ schema.course to identify the same relation uniquely.



  1. 关系具有一个架构,该架构是该关系的所有
    属性的集合。 模式指的是模式。在上面的引用中,
    似乎对应于多个关系。是否执行模式上面的
    中的引用与关系的模式相同吗?

  2. 目录和数据库之间的关系是什么?目录和数据库之间的关系
    是一对一的吗?

  3. 在mysql,postgresql或
    SQL Server中,目录和架构是什么样的?

谢谢。

推荐答案

您在#中的第一句话1没有意义。

Your first sentence in # 1 makes no sense.

表/关系(例如 person)具有属性/列(例如 name, phone和 email)。

A table/relation like "person" has attributes/columns like "name", "phone", and "email".

表在称为模式的命名空间中分组在一起。因此,诸如仓库之类的架构可以具有一个名为人的表,而诸如销售之类的另一个架构也可以具有一个偶然地名为人的表。每个目录都有一个或多个模式,每个模式都带有一个名称,例如在此处看到的仓库和销售。

Tables are grouped together in a namespace known as a schema. So a schema such as "warehouse" can have a table named "person" while another schema such as "sales" can also have a table coincidentally named "person". Each catalog has one or more schema, each schema carrying a name such as "warehouse" and "sales" seen here.

除了作为名称空间之外,模式通常还充当安全边界。据我所知,这是一个实现细节,SQL标准并不需要。

A schema commonly acts a security boundary, besides being a namespace. As far as I know, that is an implementation detail, not required by the SQL standard.

模式一词也通常以不同,更随意,更笼统的方式用于描述表格和表格。可以根据应用程序的需求进行色谱柱设计选择。请参阅下面的IMSoP的第一条评论。随意意义上的模式可能涉及正式SQL标准意义上的任意数量的目录,模式,表和列。

The word "schema" is also commonly used in a different, more casual and general way, to describe the tables & columns design choices made to fit the needs of an application. See first comment by IMSoP below. A schema in the casual sense might involve any number of catalogs, schemas, tables, and columns in the formal SQL Standard sense.

至于#2,您的引用说明了这一点。 目录和数据库是同义词。 SQL标准正式使用目录一词。

As for # 2, your quotation explains that. "Catalog" and "database" are synonyms. The word "catalog" is used formally by the SQL standard.

对于#3,努力实现SQL标准的高级数据库通常支持该标准定义的所有级别:cluster> catalog> schema> table。这包括Postgres和Microsoft SQL Server。

For # 3, advanced databases striving to implement the SQL standard typically support all levels defined by the standard: cluster > catalog > schema > table. This includes both Postgres and Microsoft SQL Server.

H2数据库引擎支持单独的数据库,每个数据库都是具有模式的目录,但是没有将目录/数据库组合在一起的集群。

H2 Database Engine supports separate databases, each being a catalog with schemas, but no cluster grouping the catalogs/databases together.

从有限的MySQL文档搜索中可以看出,MySQL受到的限制更大,并且不支持完整的层次结构。

MySQL is more limited and does not support the full hierarchy, from what I can tell in my limited searching of MySQL documentation.

有关更多信息,请参见以下相关问题:关系数据库中的目录和模式之间有什么区别?

For more info, see this related Question: What's the difference between a catalog and a schema in a relational database?

这篇关于模式和目录是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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