This set of Advanced Database Management System focuses on Relational Algebra MCQs (Multiple Choice Questions and Answers).

#### 1. The relational Algebra is a ____________ Query language.

- Structured
- Procedural
- Logical
- Relational

The Relational algebra is a procedural Query language. it consists of a set of operations that take one or two relations as input and produce a new relation as their result.

#### 2. Which of the following are the fundamental operations in the Relational Algebra?

- Select and Project
- Project and Cartesian product
- Union and set Difference
- All of the Above

The fundamental operations in the relational algebra are select, union, set difference, Cartesian product and rename

#### 3. The select, project and rename operations are called____

- Binary operations
- Ternary Operations
- Unary operations
- None of the above.

The select, project and rename operations are called unary operations, because they operate on one relation.

#### 4. Which of the following is the Binary Operations?

- Set difference, Union, Project
- Rename, union, Set difference
- Cartesian product, Set difference and project
- Cartesian product, union, set difference

Cartesian product, union, set difference are three operations operate on pair of relations and are therefore, called Binary operations.

#### 5. The select operation selects tuples that satisfy a given predicate. We use the lowercase______ to denote selection

- Greek letter rho (ρ)
- Greek letter Pi (π)
- Greek letter sigma (σ)
- Greek letter sigma (ρ)

For example to select those tuples of the * customer* relation where the

*is ‘LEO’, we write*

__customer-name__σ* customer-name*=’LEO’ (* customer*)

#### 6. Suppose we want to list all loan numbers and the amount of the loans, but do not care about the branch name. Which of the following operation allows us to produce this relation?

- Set difference
- Union
- Cartesian product
- Project

we write the query to list all the loan numbers and the amount of the loan as

π* loan-number, amount (loan)*

#### 7. The Project operation selects tuples with some attributes that we wish to include but some attribute we do not want to include in the final relation. We use the lowercase______ to denote Project operation.

- Greek letter rho (ρ)
- Greek letter Pi (π)
- Greek letter sigma (σ)
- Greek letter sigma (ρ)

#### 8. The Binary operation Union, denoted, as in the set theory by _____

- U
- ρ
- σ
- π

#### 9. If we want to include attributes from two different relations, which of the following operations is needed?

- Set difference
- Union
- Cartesian product
- Projection

Consider a Query to find the names of all bank customers who have either an account or a loan or both. Note that the customer relation does not contain the information, since a customer does not need to have either an account or a loan at bank. To answer this query we the information in the depositor relation and in the borrower relation.

So the expression needed is

Π *customer-name* (__borrower__) U Π *customer-name* (__depositor__)

#### 10. Which of the following operation allows us to find the tuples that are in one relation but are not in another relation?

- Set difference
- Union
- Cartesian product
- Set intersection

The set-difference operations, denoted by (-) ,allows to find tuples that are in one relation but are not in another. The expression *r - s* produces a relation containing those tuples in *r* but not in *s .*

For example we can find all customers of the bank who have an account but not a loan by writing

π* customer-name (depositor) - *π* customer-name (borrower)*

#### 11. Which of the following operation, denoted by cross (×), allows to combine the information from any two relation.

- Set difference
- Union
- Cartesian product
- Set intersection

#### 12. Suppose we wish to find all customers who have both a loan and an account. Which of the following operation allows us to produce this relation?

- Set difference
- Union
- Cartesian product
- Set intersection or set difference

Note that we can rewrite any relational algebra expression that uses set intersection by replacing the intersection operation with a pair of set-difference operations as:

*r ∩ s = r – (r - s)*

it is simply more convenient to write *r ∩ s *that to write *r – (r - s)*

#### 13. Which of the following operation that allows us to combine certain selections and a Cartesian product into one operation?

- Set-intersection operation
- Natural-Join operation
- Division operation
- Assignment operation

The natural join operation forms a Cartesian product of its two arguments, performs a selection forcing equality on those attributes that appear in both relation schemas, and finally removes duplicate attributes.

For example

*π customer-name, loan.loan-number, amount ( σ borrower.loan-number = loan.loan-number (borrower** ⨉ loan**))*

#### 14. Natural join operation is denoted by symbol____

- U
- ρ
- σ
- ⨝

*π customer-name, loan.loan-number, amount ( σ borrower.loan-number = loan.loan-number (borrower** ⨉ loan**))*

We express the above Query by using natural join as follows:

*π customer-name, loan.loan-number, amount (borrower* ⨝* loan**)*

#### 15. It is convenient at times to write a relational algebra expression by assigning parts of it to temporary relation variables. Which of the following operation will be used for that?

- Division
- Addition
- Assignment
- Subtraction

With the assignment operation, a query can be written as a sequential program consisting of a series of assignments followed by an expression whose value is displayed as the result of the query.

#### 16. Which of the following symbol can be used for Assignment operation in the relational algebra expression?

- =
- =+
- ==
- ←

#### 17. Which of the following take a collection of values and return a single value as a result?

- Join Operation
- Generalized Projection
- Aggregate Function
- All of the above

For example, the aggregate function * sum *takes a collection of values and returns the sum of the values. Thus the function

*applied on the collection*

__sum__#### 18. Which of the following operation behave just like join operations except on tuples that do not occur in the join results?

- Outer join
- Generalized Projection
- Projection
- Union, intersection, difference

The outer-join operation is an extension of the join operation to deal with missing information.

#### 19. Which of the following Statements stands true for Left outer-join?
- The left outer join takes all tuples in the left relation that did not match with any tuple in the right relation, pads the tuples with null values for all other attributes from the right relation, and add them to the result of the natural join.
- It pads tuples from the right relation that did not match any from the left relation with nulls and adds them to the result of the natural join.
- it pads tuples from the left relation that did not match any from the right relation,as well as tuples from the right relation that did not match any from the left relation,abd adding them to the result of join
- It takes all tuples in the right relation that did not match with any tuple in the right relation, pads the tuples with null values for all other attributes from the right relation, and add them to the result of the natural join.

- Only 1
- Only 2
- 1 and 2
- only 4

#### 20. Which of the following Statements stands true for Right outer-join?
- The left outer join takes all tuples in the left relation that did not match with any tuple in the right relation, pads the tuples with null values for all other attributes from the right relation, and add them to the result of the natural join.
- It pads tuples from the right relation that did not match any from the left relation with nulls and adds them to the result of the natural join.
- it pads tuples from the left relation that did not match any from the right relation, as well as tuples from the right relation that did not match any from the left relation, and adding them to the result of join
- It takes all tuples in the right relation that did not match with any tuple in the right relation, pads the tuples with null values for all other attributes from the right relation, and add them to the result of the natural join.

- Only 1
- Only 2
- 1 and 2
- only 4

#### 21. Which of the following Statements stands true for Full outer-join?
- The left outer join takes all tuples in the left relation that did not match with any tuple in the right relation, pads the tuples with null values for all other attributes from the right relation, and add them to the result of the natural join.
- It pads tuples from the right relation that did not match any from the left relation with nulls and adds them to the result of the natural join.
- it pads tuples from the left relation that did not match any from the right relation, as well as tuples from the right relation that did not match any from the left relation, and adding them to the result of join
- It takes all tuples in the right relation that did not match with any tuple in the right relation, pads the tuples with null values for all other attributes from the right relation, and add them to the result of the natural join.

- Only 1
- Only 2
- 1 and 2
- only 3