Введение
В реляционной алгебре, выбор (иногда называемый ограничением в связи со статьей Э. Ф. Кодда 1970 года, а не, вопреки распространенному мнению, чтобы избежать путаницы с использованием SELECT в SQL, поскольку статья Кодда была написана до появления SQL) – это унарная операция, обозначающая подмножество отношения. Выбор записывается как σ<sub>θ</sub>(R) или σ<sub>a θ v</sub>(R), где:
a и b – имена атрибутов;
θ – бинарная операция из заданного множества;
v – константное значение;
R – отношение.
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
Выбор σ<sub>a θ b</sub>(R) обозначает все кортежи в R, для которых θ выполняется между атрибутами a и b. Выбор σ<sub>a θ v</sub>(R) обозначает все кортежи в R, для которых θ выполняется между атрибутом a и значением v.
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
В качестве примера рассмотрим следующие таблицы, где первая таблица представляет отношение Person, вторая – результат σ<sub>a θ b</sub>(R), а третья – результат σ<sub>a θ v</sub>(R):
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
Name Age Weight
Harry 34 80
Sally 28 64
George 29 70
Helena 54 54
Peter 34 80
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
Name Age Weight
Harry 34 80
Helena 54 54
Peter 34 80
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
Name Age Weight
Helena 54 54
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
Более формально семантика выбора определяется следующим образом:
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
Результат выбора определен только в том случае, если имена атрибутов, используемые в условии, присутствуют в заголовке отношения, над которым выполняется операция.
or where:
a and b are attribute names
θ is a binary operation in the set
v is a value constant
R is a relation
The selection denotes all tuples in R for which θ holds between the a and the b attribute. The selection denotes all tuples in R for which θ holds between the a attribute and the value v.
For an example, consider the following tables where the first table gives the relation Person, the second table gives the result of and the third table gives the result of
Name
Age
Weight
Harry
34
80
Sally
28
64
George
29
70
Helena
54
54
Peter
34
80
Name
Age
Weight
Harry
34
80
Helena
54
54
Peter
34
80
Name
Age
Weight
Helena
54
54
More formally the semantics of the selection is defined as
follows:
The result of the selection is only defined if the attribute names that it mentions are in the heading of the relation that it operates upon.
Компьютерные языки
В компьютерных языках предполагается, что в качестве условия отбора может использоваться любое выражение, возвращающее логическое значение, а не только простое сравнение. В SQL отбор осуществляется с помощью определений WHERE в операторах SELECT, UPDATE и DELETE, однако следует отметить, что условие отбора может иметь одно из трех логических значений (истина, ложь и неизвестно) вместо обычных двух. В SQL общий отбор выполняется с использованием определений WHERE с операторами AND, OR или NOT в операторах SELECT, UPDATE и DELETE.