๐ข๏ธ Relational Algebra | ๐Includes Practice Problems for Engineer Exam
Summary
Learn the operators and characteristics of relational algebra, a core concept for the Information Processing Engineer practical exam. Understand the difference between procedural and non-procedural languages and prepare perfectly for the exam with actual past questions.
Past exam questions have been simple, asking for the symbols.
Study just enough to be able to solve the problems below.
What is Relational Algebra?
Relational algebra is a procedural formal language that describes how to find desired data in a relational database. It consists of a set of operations that take one or more relations (tables) as input and produce a new relation as a result.
Relational Algebra vs. Relational Calculus: Procedural vs. Non-Procedural Languages
Database languages are broadly divided into procedural languages and non-procedural (declarative) languages.
-
Procedural Language
- Specifies "How" to access and retrieve data.
- It describes the specific processing steps and sequence to obtain the desired result.
- Relational algebra is a prime example. The order of operations, such as whether to perform a
SELECT
or aJOIN
first, is defined.
-
Non-procedural Language
- Specifies only "What" is desired.
- It declares only what result is wanted, leaving the specific method or procedure to the system (DBMS).
- Relational calculus and SQL are prime examples. The user only specifies the conditions for the desired data, like
SELECT * FROM ... WHERE ...
, and the internal processing procedure is determined by the DBMS optimizer.
Therefore, you can understand relational algebra as a language centered on the 'process', while relational calculus is centered on the 'goal'.
Relational Algebra Operators
Relational algebra operators are broadly divided into general set operators and pure relational operators.
General Set Operators
Based on mathematical set theory, they require the two relations to be Union-compatible. (The two relations must have the same number of attributes, and the domains of corresponding attributes must be the same).
Operator | Symbol | Description |
---|---|---|
Union | โช | Returns a relation containing all tuples from both relations (duplicates excluded). |
Intersection | โฉ | Returns a relation consisting only of tuples that exist in both relations. |
Difference | - | Returns tuples that are in the first relation but not in the second. |
Cartesian Product | ร | Returns all possible tuples by pairing tuples from two relations. |
Pure Relational Operators
These are operators created specifically for the relational database model.
Operator | Symbol | Description |
---|---|---|
Select | ฯ | Returns a horizontal subset of tuples (rows) that satisfy a given condition. |
Project | ฯ | Returns a vertical subset of attributes (columns), with duplicates excluded. |
Join | โ | Combines two relations based on a common attribute to create a new relation. |
Division | รท | Returns tuples from relation A that are related to all tuples in relation B. |
๐ Practice Problems for the Information Processing Engineer Exam
From the options below, find the correct relational algebra operator symbol and write it in the answer field.
[Options]
ฯ
, ฯ
, โ
, รท
, โช
, โฉ
, -
, ร
Problem | Write the symbol for the Select relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |
Problem | Write the symbol for the Project relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |
Problem | Write the symbol for the Join relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |
Problem | Write the symbol for the Division relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |
Problem | Write the symbol for the Union relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |
Problem | Write the symbol for the Intersection relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |
Problem | Write the symbol for the Difference relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |
Problem | Write the symbol for the Cartesian Product relational algebra operator. |
Your Answer | |
Correct Answer | Reveal Answer |