written 2.2 years ago by |
1] Select. $(\sigma)$
2] Project. $(\pi)$
3] Set intersection. (n)
4] Natural join.
1] Select $(\sigma)$ - It is used to specify any condition on relation.
syntax
$\sigma$ condition (R)
condition is executed on relation R.
$\sigma$ sal>1000 (customer)
when this query is executed all customers whose salary is more than 1000 are displayed.
we can use >, <, >=, <=, <> operator for comparision.
we can combine two conditions with or (v) or AND (n) operator.
$\sigma$ ename = 'Rohit' ^ Sal > 10000 (customer)
2] Project. $(\pi)$ - It is used to display selected list of attribute of relation.
Syntax
$\pi$ <attribute list> (R)
eg. Consider
emp (emp no, name, email, salary)
example:
$\pi$ name, email (emp)
This will display employee name, email from emp table.
3] Set interaction (n) - This operation is used to find the common tuple from temp relation.
consider temp relations R & S.
R
A | B |
---|---|
a | 1 |
a | 2 |
b | 1 |
S
A | B |
---|---|
a | 2 |
b | 3 |
b | 1 |
R n S
A | B |
---|---|
a | 2 |
b | 1 |
Natural Join:
This is binary operation and is message to join the temp relation having a common column, Both relations are joined based on common values.
R
A | B |
---|---|
a | 1 |
a | 2 |
b | 1 |
C
A | B |
---|---|
a | 2 |
b | 3 |
R X C
A | B | A | C |
---|---|---|---|
a | 1 | a | 2 |
a | 1 | b | 3 |
a | 2 | a | 2 |
a | 2 | b | 3 |
b | 1 | a | 2 |
b | 1 | b | 3 |