zoukankan      html  css  js  c++  java
  • 数据系统结构之关系操作(翻译)

    Published by McGraw-Hill, a business unit of The McGraw-Hill Companies, Inc., 1221 Avenue of the Americas, New York, NY 10020. Copyright © 2011 by The McGraw-Hill Companies, Inc.

    All rights reserved. Previous editions © 2006, 2002, and 1999.

    此文为自己的翻译译文,上文为原文链接,如有雷同,敬请谅解

    Relational Operations

    关系操作

    All procedural relational query languages provide a set of operations that

    can be applied to either a single relation or a pair of relations.

    所有的程序上的关系运算语言都提供了一系列可以应用于单方面或者是双方的关系运算

    所有的过程关系查询语言都提供了一组操作可以应用于单个关系或一对关系。

    These operations have the nice and desired property that their result is always a single relation.

    这些操作具有良好的和所需的属性,它们的结果始终是单个关系。

    This property allows one to combine several of these operations in a modular way.

    在某种程度上,这个属性可以允许一种运算结合另外集中运算

    此属性允许以模块方式组合多个操作。

    Specifically, since the result of a relational query is itself a relation, relational operations can be applied to the results of queries as well as to the given set of relations.

    具体来说,由于关系查询的结果本身就是一个关系,因此关系操作可以应用于查询的结果以及给定的关系集

    The specific relational operations are expressed differently depending on the language, but fit the general framework we describe in this section.

    那个特别的关系操作根据不同语言不同地表达,但是符合我们在这个部分表达的总体结构

    In Chapter 3, we show the specific way the operations are expressed in SQL .

    在第三章,我们展示了操作关系在SQL中的表达

    The most frequent operation is the selection of specific tuples from a sin-

    gle relation (say instructor) that satisfies some particular predicate (say salary >$85,000).

    最常见的操作就是从一个部分中选择特定的元组关系(比如讲师),它满足某些特定的谓词(比如$ 85,000) 

    The result is a new relation that is a subset of the original relation。

     结果就是,新的关系就是一个最初的操作子集入手

    Figure 2.10 Result of query selecting instructor tuples with salary greater than $85000. structor).

    关系查询引导教师薪资大于85000美元

    For example, if we select tuples from the instructor relation of Figure 2.1, satisfying the predicate salary is greater than $85000, we get the result shown in Figure 2.10. 

    例如,如果我们从教师关系表2.1挑选符合条件(薪资大于85000美元)的,我们会从表格2.10获得结果

    Another frequent operation is to select certain attributes (columns) from a relation.

    另外一个操作就是从关系表中选择确定的元素

     The result is a new relation having only those selected attributes.

    结果是一个新的只有被选出来的关系

    For example, suppose we want a list of instructor ID s and salaries without listing the name and dept name values from the instructor relation of Figure 2.1, then the result, shown in Figure 2.11, has the two attributes ID and salary.

    例如,假设我们不用从关系表格2.1列出名字和部门名字就可以得到一系列的教师身份证和薪水,并把这些体现在表格2.11

    Each tuple in the result is derived from a tuple of the instructor relation but with only selected attributes shown.

    在结果中每个教师被从一个教师关系表格但是只有被挑选到的会显现

    The join operation allows the combining of two relations by merging pairs of tuples, one from each relation, into a single tuple.

    那个联结的操作允许两个关系结合在一起,每个关系从很多关系而来,只记录在一个表格

    There are a number of different ways to join relations (as we shall see in Chapter3). 

    有很多不同方法去结合关系,就像我们在第三章看见的那样

    Figure2.12 shows an example of joining the tuples from the instructor and department tables with the new tuples showing the information about each instructor and the department in which she is working.

    表格2.12展示了一个把从教师和公寓表格组成一个新的表格,可以展示每个教师和他在哪儿工作

    This result was formed by combining each tuple in the instructor relation with the tuple in the department relation for the instructors department.

    这个结果由每个展示教师关系的表格结合而成,每个表格都展示了部门关系中教师部门

    In the form of join shown in Figure 2.12, which is called a natural join, a tuple from the instructor relation matches a tuple in the department relation if the values .

    在表格的自然连接中,如果可以的话,一个表格的教师关系可以匹配一个部门的关系表格

    Figure 2.11 Result of query selecting attributes ID and salary from the instructor relation.

    表格2.11是从教师关系中查询身份证和薪水

    Figure 2.12 Result of natural join of the instructor and department relations.of their dept name attributes are the same.

    表格2.12把教师和部门的连接表格部门名字相同

    All such matching pairs of tuples are present in the join result.

    每个匹配的元组都代表连接结果

    In general, the natural join operation on two relations matches tuples whose values are the same on all attribute names that are common to both relations.

    总之,一般来说,两种关系的自然连接操作都匹配tuple,它们的值对于两种关系中的所有属性名称都是相同的。

    The Cartesian product operation combines tuples from two relations,but unlike the join operation, its result contains all pairs of tuples from the two relations,regardless of whether their attribute values match.

    The Cartesian产品操作结合两个操作,但是不像连接操作,它的结果包括所有从两个表格选的元组,除了他们匹配的属性值

    Because relations are sets, we can perform normal set operations on relations.

    因为操作已经完成,我们可以在关系上展示正常操作

    The union operation performs a set union of two similarly structuredtables(say a table of all graduate students and a table of all undergraduate students)

    联合操作展示了一种两个相似结构表格联合(就是一个毕业学生和在校学生的表格)

    .For example, one can obtain the set of all students in a department. Other set operations, such as intersection and set difference can be performed as well.

    例如,一个可以包括一个部门里的所有学生,其他的操作,比如交集和不同也可以很好呈现

    As we noted earlier, we can perform operations on the results of queries.

    就像我们之前提到的,我们可以在查询结果中操作

    For example,if we want to find the ID and salary for those instructors who have salary greater than $85,000, we would perform the first two operations in our example above.

    例如,我们想要查询身份证和薪水超过85000美元的教师,我们可以输入上文上个例子的操作

     First we select those tuples from the instructor relation where the salary value is greater than $85,000 and then, from that result, select the two attributes ID and salary, resulting in the relation shown in Figure 2.13 consisting of the ID 

    第一我们可以从那些关系表格选择符合条件的元组,然后从结果选择两个身份属性和薪水,最后展现在表格2.13

     2.6 Relational Operations 51

    2.6关系操作

    RELATIONAL ALGEBRA

    关系代数

    The relational algebra defines a set of operations on relations, paralleling the usual algebraic operations such as addition,subtraction or multiplication,which operate on numbers.

    关系代数定义了一系列的关系操作,将通常的代数运算,例如加法、减法运算和乘法运算,并联在数字上。

    Just as algebraic operations on numbers take one or more numbers as input and return a number as output, the relational algebra operations typically take one or two relations as input and return a relation as output. 

    只是一个或多个数字上的代数操作,关系代数操作通常花费一个或者两个关系像输入和输出一个关系

    Relational algebra is covered in detail in Chapter 6, but we outline a few of the operations below and salary.

    第六章覆盖了关系代数,但是我们只列出一下以下的操作

     In this example, we could have performed the operations in either order, but that is not the case for all situations, as we shall see.

    在这个例子当中,我们可以在另外的命令中操作但是这不是所有我们看到的例子

    Sometimes,the result of a query contains duplicate tuples.

    有时查询结果包含了元组

    For example, if we select the dept name attribute from the instructor relation, there are several cases of duplication, including Comp. Sci., which shows up three times.

    例如,如果我们从教师选择部门名字属性从教师关系表,有一些是很少的重复,包括出现了三次的Comp. Sci.

    Certain relational languages adhere strictly to the mathe matical definition of a set and remove duplicates.

    某些关系语言严格遵守设置的mathe matical定义,并删除重复。

    Others, in consideration of the relatively large amount of processing required to remove duplicates from large result relations, retain duplicates.

    其他的,考虑到相对较大的程序要求去移出重复

    In these latter cases, the relations are not truly relations in the pure mathematical sense of the term.

    在这些例子当中,关系不仅是完全数学物品关系

    Of course, data in a database must be changed over time.

    当然,在数据库的数据一定会一直改变

    A relation can be updated by inserting new tuples, deleting existing tuples, or modifying  tuples  by 52 Chapter 2 Introduction to the Relational Model changing the values of certain attributes.

    一个关系表可以保存插入的新元组

    Entire relations can be deleted and new ones created.

    整个关系可以被删除或重建

    We shall discuss relational queries and updates using the SQL language in Chapters 3 through 5.

    我们会在第三章到第五章讨论关系查询和存储用SQL语言

    Summary

    总结

    The relational data model is based on a collection of tables.

    关系数据模型是基于表格收集

    The user of the database system may query these tables, insert new tuples, delete tuples, and update (modify) tuples.

    数据库系统的使用查询这些表格,插入新元组,删除元组和下载元组

    There are several languages for expressing these operations.

    这些事解释这些操作的语言

    The schema of a relation refers to its logical design, while an instance of the relation refers to its contents at a point in time.

    •关系的图式是指它的逻辑设计,而关系的实例指的是它在某一时刻的内容。

    The schema of a database and an instance of a database are similarly defined.

    同样定义了数据库的模式和数据库的实例。

    The schema of a relation include sits attributes, and optionally the types of the attributes and constraints on the relation such as primary and foreign key constraints.

    关系的模式包括属性,以及可选的属性类型和约束关系,如主键和外键约束。

    A superkey of a relation is a set of one or more attributes whose values are guaranteed to identify tuples in the relation uniquely.

    一个超码的关系是一个或多个属性的值被保证去认定元组

    A candidate key is a minimal superkey, that is, a set of attributes that forms a superkey, but none of whose subsets is a superkey.

    一个候选人是一个重要的主键,就是一个表格的属性,但是没有任何一个子集是主键

    One of the candidate keys of a relation is chosen as its primary key.

    其中的候选键是从主键选出来的

    A foreign key is a set of attributes in a referencing relation, such that for each tuple in the referencing relation, the values of the foreign key attributes are guaranteed to occur as the primary key value of a tuple in the referenced relation.

    外键是一系列关系中的属性,在关系中的各个元组,外键的值的属性要一定是元组的主键

    A schema diagram is a pictorial depiction of the schema of a database that shows the relations in the database, their attributes, and primary keys and foreign keys.

    •模式图是一个数据库模式的图形描述,它显示数据库中的关系、它们的属性、主键和外键。

    The relational query languages define a set of operations that operate on tables, and output tables as their results.

    关系查询语言定义了一系列的操作,作用于表格和结果的表格

    These operations can be combined to get expressions that express desired queries.

    这些操作可以被组合去得到查询表达

    The relational algebra provides a set of operations that take one or more relations as input and return are lationasan output.

    •关系代数提供了一组操作,它们以一个或多个关系作为输入,而返回是lationasan输出。

    Practical query  实用查询

    Languages such as SQL are based on the relational algebra, but add a number of useful syntactic features.

    像基于关系代数的SQL语言,但是加入了一系列的有用的元素

  • 相关阅读:
    Tomcat启动报Error listenerStart错误
    The type javax.xml.rpc.ServiceException cannot be resolved.It is indirectly
    (转)Android之Adapter用法总结
    利用脚本启动java程序
    Android中的基类—抽取出来公共的方法
    关于 Android 中未公开的类(用@hide隐藏的类)
    Android java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
    gen already exists but is not a source folder
    如何注册java程序为windows服务
    Android Socket编程
  • 原文地址:https://www.cnblogs.com/lzy35/p/7615495.html
Copyright © 2011-2022 走看看