Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Tests  >  Question Bank for GATE Computer Science Engineering  >  Test: Joins in Relational Algebra - Computer Science Engineering (CSE) MCQ

Test: Joins in Relational Algebra - Computer Science Engineering (CSE) MCQ


Test Description

10 Questions MCQ Test Question Bank for GATE Computer Science Engineering - Test: Joins in Relational Algebra

Test: Joins in Relational Algebra for Computer Science Engineering (CSE) 2024 is part of Question Bank for GATE Computer Science Engineering preparation. The Test: Joins in Relational Algebra questions and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus.The Test: Joins in Relational Algebra MCQs are made for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Joins in Relational Algebra below.
Solutions of Test: Joins in Relational Algebra questions in English are available as part of our Question Bank for GATE Computer Science Engineering for Computer Science Engineering (CSE) & Test: Joins in Relational Algebra solutions in Hindi for Question Bank for GATE Computer Science Engineering course. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free. Attempt Test: Joins in Relational Algebra | 10 questions in 30 minutes | Mock test for Computer Science Engineering (CSE) preparation | Free important questions MCQ to study Question Bank for GATE Computer Science Engineering for Computer Science Engineering (CSE) Exam | Download free PDF with solutions
Test: Joins in Relational Algebra - Question 1

Consider two database relations R and S having 3 tuples in R and 2 tuples in S. what is the maximum number of tuples that could appear in the natural join of R and S?

Detailed Solution for Test: Joins in Relational Algebra - Question 1

Concept:
If there are two relations A and B with m and n number of tuples respectively. Then maximum number of tuples in their natural join will be m*n. Maximum tuples will be when one attribute will contain all same values as the other relation having same attribute.
Given: two relations R and S having tuples 3 and 2 respectively. 
So, their natural join will contain maximum of 3 * 2= 6 tuples.
Example:
Consider table R (a, b) as ;

Relation S(a, c) as :

Here, the natural join of R and S will be :

So, it contains total of 6 tuples.

Test: Joins in Relational Algebra - Question 2

Which of the following Relational Algebra operations can be used when you want to keep all the tuples of the first relation irrespective of whether or not they have matching tuples in the second relation?

Detailed Solution for Test: Joins in Relational Algebra - Question 2

A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
Here are the different types of the JOINs in SQL:

  • (INNER) JOIN: Returns records that have matching values in both tables
  • LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
  • RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
  • FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table

We can see that left join keeps all the elements from the first relation irrespective of their presence in second relation.

Diagram to visualize joins:

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Joins in Relational Algebra - Question 3

Let the following functional dependencies hold for relation R1(A, B, C) and R2(B, D, E)
B → A, A → C, the relation R1 contains 35 tuples and relation R2 contains 34 tuples. What is maximum number of tuples possible in natural join R1 and R2?

Detailed Solution for Test: Joins in Relational Algebra - Question 3

For given relation R1(A, B, C) and R2(B, D, E), functional dependencies are given only for relation R1, not for R2 And the candidate key for R1 is B, so all 35 value must be unique in R1. To get the maximum number of tuples in output, there can be two possibilities.
1) All 34 values of B in R2 are the same and there is an entry in R1 that matches with this value. In this case, we get 34 tuples in output.
Example:
Consider an example, suppose there is two tables R1(A, B, C) consists of 5 tuples and R2( B, D, E) consists of 4 tuples only.


Natural join of R1 and R2 (R1 * R2) gives: 4

2) All 34 values of B in R2 are different and these values are present in R1 also. In this case also, we get 34 tuples.
Example:
Consider an example, suppose there is two tables R1(A, B, C) consists of 5 tuples and R2( B, D, E) consists of 4 tuples only.


Natural join of R1 and R2 (R1 * R2) gives: 4

Test: Joins in Relational Algebra - Question 4

In relational databases, the natural join of two tables is:

Detailed Solution for Test: Joins in Relational Algebra - Question 4

Concept
Natural join is used to join two relations having any number of attributes. It is denoted by a symbol ( ⨝). It is the combination of projection and filtered cartesian product. It optimizes the query as the cartesian product gives unnecessary results and set union and set intersection operations are application only on those relations that have an equal number of attributes with the same data types. 
Example: Given two relation employee and departments. 
Employee:

Department:

Query: Find the name of all employees from Employee with their respective Department names using natural join :
The result will be : 

Test: Joins in Relational Algebra - Question 5

Consider Join of a relation R with a relation S. If R has m tuples and S has n tuples, then maximum and minimum sizes of the Join respectively are

Detailed Solution for Test: Joins in Relational Algebra - Question 5

Concept: 
A natural join (join) is based on common attributes or common columns to join two tables or relations.
Consider an example, suppose there is two tables Employee(Eid, Ename) consists of 5 tuples and department(Eid, Did) consists of 3 tuples only.


Natural join of employee and department(Employee * Department) gives:
m×n = 5 × 3 = 15
Therefore maximum size is m × n
Minimum size: 
When Both the relations have a common attribute but no tuple in both relations match.
∴ minimum size = 0.

Test: Joins in Relational Algebra - Question 6

Consider a join (relation algebra) between relations r(R)and s(S) using the nested loop method.
There are 3 buffers each of size equal to disk block size, out of which one buffer is reserved for intermediate results.
Assuming size(r(R))

Detailed Solution for Test: Joins in Relational Algebra - Question 6

Concept:
Nested loop join algorithm:
No of block transfers = nr x bs + br
Where nr is number of tuples in relation R and bs and br are the number of blocks in relation R and S respectively.
In question it is given that size(r(R))s > br and nr < ns.
Example:
Suppose relation r is in the outer loop:

Suppose relation s is in the outer loop:
Block transfer = 100 x 10 + 20 = 1020
So relation r should be in the outer loop for effective nested loop join algorithm.
Hence option 1 is the correct answer.

Test: Joins in Relational Algebra - Question 7

Joining a table with itself is called

Detailed Solution for Test: Joins in Relational Algebra - Question 7

Self-Join:
A self-join is a join in which the table is joined with itself to get the appropriate results. In this case, it is necessary to ensure that the join statement defines an ALIAS name for both copies of the tables to avoid column ambiguity.
Example:

Query:
SELECT A. Coursename AS Course, B. Coursename AS Prerequisite_Course
FROM Course A, Course B
WHERE, A.Precourse = B.CourseID;
OUTPUT

Test: Joins in Relational Algebra - Question 8

The following functional dependencies hold for relations R(A, B, C) and S(B, D, E)
B → A,
A → C
The relation R contains 200tuples and the relation S contains 100tuples. What is the maximum number of tuples possible in the natural join R⋈S ?

Detailed Solution for Test: Joins in Relational Algebra - Question 8

For given relation R1(A, B, C) and R2(B, D, E), functional dependencies are given only for relation R1, not for R2 And the candidate key for R1 is B, so all values must be unique in R1. To get the maximum number of tuples in output, there can be two possibilities.
1) All 100 values of B in R2 are the same and there is an entry in R1 that matches with this value. In this case, we get 100 tuples in output.
Example:
Consider an example, suppose there is two tables R1(A, B, C) consisting of 5 tuples and R2( B, D, E) consisting of 4 tuples only.



Natural join of R1 and R2 (R1 * R2) gives: 4
2) All 100 values of B in R2 are different and these values are present in R1 also. In this case, also we get 100 tuples.
Example:
Consider an example, suppose there is two tables R1(A, B, C) consists of 5 tuples and R2( B, D, E) consists of 4 tuples only.


Natural join of R1 and R2 (R1 * R2) gives: 4

Test: Joins in Relational Algebra - Question 9

Consider two relations R1(A, B) with the tuples (1, 5), (3, 7) and R2(A, C) = (1, 7), (4, 9). Assume that R(A, B, C) is the full natural outer join of R1 and R2. Consider the following tuples of the form (A, B, C): a = (1, 5, null), b = (1, null, 7), c = (3, null, 9), d = (4, 7, null), e = (1, 5, 7), f = (3, 7, null), g = (4, null, 9). Which one of the following statements is correct?

Detailed Solution for Test: Joins in Relational Algebra - Question 9


Full natural outer join of R1 and R2 is :

Hence option 3 is correct:

Test: Joins in Relational Algebra - Question 10

Consider the relations r(A, B) and s(B, C), where s.B is a primary key and r.B is a foreign key referencing s.B. Consider the query

Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values.
Which one of the following queries is NOT equivalent to Q?

Detailed Solution for Test: Joins in Relational Algebra - Question 10

 will include record with b > = 5 but other three queries will not.

63 videos|7 docs|165 tests
Information about Test: Joins in Relational Algebra Page
In this test you can find the Exam questions for Test: Joins in Relational Algebra solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Joins in Relational Algebra , EduRev gives you an ample number of Online tests for practice

Top Courses for Computer Science Engineering (CSE)

Download as PDF

Top Courses for Computer Science Engineering (CSE)