Tuesday, August 15, 2017

selection operation in relational algebra

selection operation in relational algebra, unary operations in relational model, unary selection operation in relational algebra

SELECT (σ) in Relational Algebra

Operation
SELECT
Type of operation
Unary
Syntax
σ <selection condition> (R)
In the above expression,
σ – selection operator
<selection condition> - <Attribute> <comparison operator> <value/other attribute>
comparison operators are {=, <, <=, >, >=, <>}
Valid Examples
Invalid
regno = ‘BIT001’
age < 65
student.regno = subject_taken.regno
regno = <’BIT001’>
65 = age

More than one conditions can be used and those conditions can be connected using logical connectives ^ (and), v (or), and ¬ (not).
Example:      
regno = ‘BIT001’ ^ age<65
student.regno = subject_taken.regno v age > 20 ^ age<65
R – Relation name [or another expression]

Function
Selects all tuples (records) that satisfy the selection condition from a relation R (or an expression).
It filters records according to the condition. It deals with the tuples (records) of a relation.

In SQL, the selection operation is specified in WHERE clause of the query.
Example 1
RA: σage>15 (student)
SQL: SELECT * FROM student WHERE age>15;
STUDENT
Regno
Name
Age
Phone

BIT001
Ram
15
8652398452
BIT023
Selvi
17
7894562310
MIS089
Kumar
16
8562314701

Result: Finds all students with age greater than 15
RESULT
Regno
Name
Age
Phone

BIT023
Selvi
17
7894562310
MIS089
Kumar
16
8562314701
Example 2
RA: σage>15^phone=9202092020 (student)
SQL: SELECT * FROM student WHERE age>15 and phone = 9202092020;

Result: Finds all students whose age greater than 15 and having phone 9202092020.
RESULT
Regno
Name
Age
Phone







*****************




No comments:

Post a Comment

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery