Fix up typos.
Move "query result" tables to left side of page (remove leading spaces).
This commit is contained in:
parent
ff7b9f5541
commit
ee7f92b76b
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.9 2000/05/02 20:01:52 thomas Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.10 2000/06/14 13:10:48 thomas Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<chapter id="sql">
|
<chapter id="sql">
|
||||||
@ -155,16 +155,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/sql.sgml,v 1.9 2000/05/02 20:01:52 thomas E
|
|||||||
<example>
|
<example>
|
||||||
<title id="supplier-fig">The Suppliers and Parts Database</title>
|
<title id="supplier-fig">The Suppliers and Parts Database</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SUPPLIER SNO | SNAME | CITY SELLS SNO | PNO
|
SUPPLIER: SELLS:
|
||||||
-----+---------+-------- -----+-----
|
SNO | SNAME | CITY SNO | PNO
|
||||||
|
----+---------+-------- -----+-----
|
||||||
1 | Smith | London 1 | 1
|
1 | Smith | London 1 | 1
|
||||||
2 | Jones | Paris 1 | 2
|
2 | Jones | Paris 1 | 2
|
||||||
3 | Adams | Vienna 2 | 4
|
3 | Adams | Vienna 2 | 4
|
||||||
4 | Blake | Rome 3 | 1
|
4 | Blake | Rome 3 | 1
|
||||||
3 | 3
|
3 | 3
|
||||||
4 | 2
|
4 | 2
|
||||||
PART PNO | PNAME | PRICE 4 | 3
|
PART: 4 | 3
|
||||||
-----+---------+--------- 4 | 4
|
PNO | PNAME | PRICE 4 | 4
|
||||||
|
----+---------+---------
|
||||||
1 | Screw | 10
|
1 | Screw | 10
|
||||||
2 | Nut | 8
|
2 | Nut | 8
|
||||||
3 | Bolt | 15
|
3 | Bolt | 15
|
||||||
@ -474,7 +476,7 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
INTERSECT (∩): builds the set-theoretic intersection of two
|
INTERSECT (∩): builds the set-theoretic intersection of two
|
||||||
tables. Given the tables <classname>R</classname> and
|
tables. Given the tables <classname>R</classname> and
|
||||||
<classname>S</classname>,
|
<classname>S</classname>,
|
||||||
<classname>R</classname> ∪ <classname>S</classname> is the
|
<classname>R</classname> ∩ <classname>S</classname> is the
|
||||||
set of tuples
|
set of tuples
|
||||||
that are in <classname>R</classname> and in
|
that are in <classname>R</classname> and in
|
||||||
<classname>S</classname>.
|
<classname>S</classname>.
|
||||||
@ -532,7 +534,8 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
Let the following two tables be given:
|
Let the following two tables be given:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
R A | B | C S C | D | E
|
R: S:
|
||||||
|
A | B | C C | D | E
|
||||||
---+---+--- ---+---+---
|
---+---+--- ---+---+---
|
||||||
1 | 2 | 3 3 | a | b
|
1 | 2 | 3 3 | a | b
|
||||||
4 | 5 | 6 6 | c | d
|
4 | 5 | 6 6 | c | d
|
||||||
@ -547,7 +550,8 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
get:
|
get:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
R x S A | B | R.C | S.C | D | E
|
R x S:
|
||||||
|
A | B | R.C | S.C | D | E
|
||||||
---+---+-----+-----+---+---
|
---+---+-----+-----+---+---
|
||||||
1 | 2 | 3 | 3 | a | b
|
1 | 2 | 3 | 3 | a | b
|
||||||
1 | 2 | 3 | 6 | c | d
|
1 | 2 | 3 | 6 | c | d
|
||||||
@ -595,8 +599,9 @@ attributes are taken from. We often write a relation scheme as
|
|||||||
C and D.
|
C and D.
|
||||||
Then we define the division as:
|
Then we define the division as:
|
||||||
|
|
||||||
R ÷ S = {t ∣ ∀ t<subscript>s</subscript> ∈ S
|
<programlisting>
|
||||||
∃ t<subscript>r</subscript> ∈ R
|
R ÷ S = {t ∣ ∀ t<subscript>s</subscript> ∈ S ∃ t<subscript>r</subscript> ∈ R
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
such that
|
such that
|
||||||
t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>s</subscript>}
|
t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>s</subscript>}
|
||||||
@ -614,7 +619,8 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
Given the following tables
|
Given the following tables
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
R A | B | C | D S C | D
|
R: S:
|
||||||
|
A | B | C | D C | D
|
||||||
---+---+---+--- ---+---
|
---+---+---+--- ---+---
|
||||||
a | b | c | d c | d
|
a | b | c | d c | d
|
||||||
a | b | e | f e | f
|
a | b | e | f e | f
|
||||||
@ -720,7 +726,10 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
<para>
|
<para>
|
||||||
The queries used in <acronym>TRC</acronym> are of the following
|
The queries used in <acronym>TRC</acronym> are of the following
|
||||||
form:
|
form:
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
x(A) ∣ F(x)
|
x(A) ∣ F(x)
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
where <literal>x</literal> is a tuple variable
|
where <literal>x</literal> is a tuple variable
|
||||||
<classname>A</classname> is a set of attributes and <literal>F</literal> is a
|
<classname>A</classname> is a set of attributes and <literal>F</literal> is a
|
||||||
@ -734,10 +743,10 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
using <acronym>TRC</acronym> we formulate the following query:
|
using <acronym>TRC</acronym> we formulate the following query:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{x(SNAME) ∣ x ∈ SUPPLIER ∧ \nonumber
|
{x(SNAME) ∣ x ∈ SUPPLIER ∧
|
||||||
∃ y ∈ SELLS ∃ z ∈ PART (y(SNO)=x(SNO) ∧ \nonumber
|
∃ y ∈ SELLS ∃ z ∈ PART (y(SNO)=x(SNO) ∧
|
||||||
z(PNO)=y(PNO) ∧ \nonumber
|
z(PNO)=y(PNO) ∧
|
||||||
z(PNAME)='Screw')} \nonumber
|
z(PNAME)='Screw')}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -806,7 +815,9 @@ t<subscript>r</subscript>(A,B)=t∧t<subscript>r</subscript>(C,D)=t<subscript>
|
|||||||
to involve
|
to involve
|
||||||
arithmetic operations as well as comparisons, e.g.
|
arithmetic operations as well as comparisons, e.g.
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
A < B + 3.
|
A < B + 3.
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
Note
|
Note
|
||||||
that + or other arithmetic operators appear neither in relational
|
that + or other arithmetic operators appear neither in relational
|
||||||
@ -1348,8 +1359,9 @@ gives the result:
|
|||||||
SNO | SNAME | CITY
|
SNO | SNAME | CITY
|
||||||
-----+-------+--------
|
-----+-------+--------
|
||||||
2 | Jones | Paris
|
2 | Jones | Paris
|
||||||
The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
|
The only tuple returned by both parts of the query is the one having $SNO=2$.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1463,7 +1475,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
<replaceable class="parameter">q</replaceable>
|
<replaceable class="parameter">q</replaceable>
|
||||||
of them right to the decimal point.
|
of them right to the decimal point.
|
||||||
|
|
||||||
(15 ≥ <replaceable class="parameter">p</replaceable> ≥ <replaceable class="parameter">q</replaceable>q ≥ 0).
|
(15 ≥ <replaceable class="parameter">p</replaceable> ≥ <replaceable class="parameter">q</replaceable> ≥ 0).
|
||||||
|
|
||||||
If <replaceable class="parameter">q</replaceable>
|
If <replaceable class="parameter">q</replaceable>
|
||||||
is omitted it is assumed to be 0.
|
is omitted it is assumed to be 0.
|
||||||
@ -1528,8 +1540,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
we use the following statement:
|
we use the following statement:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
CREATE INDEX I
|
CREATE INDEX I ON SUPPLIER (SNAME);
|
||||||
ON SUPPLIER (SNAME);
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1612,8 +1623,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
if it were another base table:
|
if it were another base table:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT *
|
SELECT * FROM London_Suppliers
|
||||||
FROM London_Suppliers
|
|
||||||
WHERE P.PNAME = 'Screw';
|
WHERE P.PNAME = 'Screw';
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
@ -1691,8 +1701,7 @@ The only tuple returned by both parts of the query is the one having $SNO=2$.
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceable class="parameter">name_of_attr_1</replaceable>
|
INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceable class="parameter">name_of_attr_1</replaceable>
|
||||||
[, <replaceable class="parameter">name_of_attr_2</replaceable> [,...]])
|
[, <replaceable class="parameter">name_of_attr_2</replaceable> [,...]])
|
||||||
VALUES (<replaceable class="parameter">val_attr_1</replaceable>
|
VALUES (<replaceable class="parameter">val_attr_1</replaceable> [, <replaceable class="parameter">val_attr_2</replaceable> [, ...]]);
|
||||||
[, <replaceable class="parameter">val_attr_2</replaceable> [, ...]]);
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user