Explain Unary relational operations with examples.

Unary Relational Operations in Relational Algebra

Unary operations are operations that are applied to a single relation (table). These are used to filter or manipulate data from one table without involving another relation.


1. SELECT (σ) — Selection

Definition:

  • Retrieves rows (tuples) from a relation that satisfy a given condition.
  • It is a horizontal subset of the relation.

Syntax:

σ<condition>(Relation)

Example:

σ age > 25 (Student)

Returns all students older than 25.


2. PROJECT (π) — Projection

Definition:

  • Retrieves specific columns (attributes) from a relation.
  • Removes duplicate rows automatically (since relations are sets).

Syntax:

π<attribute list>(Relation)

Example:

π name, age (Student)

Returns the name and age columns from the Student table, removing duplicates.


3. RENAME (ρ) — Renaming

Definition:

  • Used to rename the relation or its attributes.
  • Useful when dealing with self-joins or complex queries.

Syntax:

ρ NewName(Relation)
OR
ρ(NewName(attr1, attr2, ...))(Relation)

Example:

ρ S(Student)

Renames the Student relation to S.

ρ Temp(sid, sname)(Student)

Renames the relation as Temp and attributes as sid, sname.


Summary Table

OperationSymbolPurposeExample
SELECTσFilters rows by conditionσ age > 25 (Student)
PROJECTπChooses specific columnsπ name, age (Student)
RENAMEρRenames relation/attributesρ S(Student)

Let me know if you want practice questions or visual examples for these operations.

Leave a Reply

Your email address will not be published. Required fields are marked *