Unit 3 - Practice Quiz

INT306

1 Which operator in Relational Algebra is used to select tuples from a relation that satisfy a specific condition?

A. (Pi)
B. (Sigma)
C. (Rho)
D. (Bowtie)

2 Which SQL aggregate function is used to calculate the total number of rows in a table, including rows with NULL values?

A. COUNT(column_name)
B. SUM(*)
C. COUNT(*)
D. TOTAL(*)

3 In Relational Algebra, which operator implies a combination of the Cartesian Product followed by a Selection?

A. Projection ()
B. Union ()
C. Join ()
D. Division ()

4 What is the result of the following SQL operation: SELECT * FROM A CROSS JOIN B if Table A has 4 rows and Table B has 3 rows?

A. 7 rows
B. 12 rows
C. 4 rows
D. 3 rows

5 Which clause is used to filter the results of aggregate functions in SQL?

A. WHERE
B. HAVING
C. ORDER BY
D. GROUP BY

6 Which Set Operator in SQL allows duplicates in the result set?

A. UNION
B. INTERSECT
C. UNION ALL
D. EXCEPT

7 In Relational Algebra, the Projection operator () is used to:

A. Select specific rows meeting a condition
B. Combine two relations
C. Select specific columns and remove duplicate tuples
D. Rename a relation

8 What is a View in SQL?

A. A physical table that stores data permanently
B. A virtual table based on the result-set of an SQL statement
C. A backup of the database
D. A temporary table stored in RAM

9 Which of the following is TRUE regarding a LEFT JOIN?

A. It returns all records from the right table, and the matched records from the left table.
B. It returns only records where there is a match in both tables.
C. It returns all records from the left table, and the matched records from the right table.
D. It returns the Cartesian product of both tables.

10 Consider relations and . Which relational algebra expression represents the Natural Join?

A.
B.
C.
D.

11 A subquery that uses values from the outer query is called a:

A. Nested Subquery
B. Correlated Subquery
C. Scalar Subquery
D. Parallel Subquery

12 Which operator is used to perform the Division operation in Relational Algebra?

A.
B.
C.
D.

13 What is the requisite condition for performing Set Union () or Set Difference () between two relations?

A. They must have a common attribute.
B. They must be Union Compatible.
C. They must have the same number of rows.
D. One must be a subset of the other.

14 In SQL, what does the MINUS (or EXCEPT) operator do?

A. Returns rows present in both queries.
B. Returns rows from the first query that are not present in the second query.
C. Returns rows from the second query that are not present in the first query.
D. Subtracts the values of one column from another.

15 Which SQL statement is used to remove a view?

A. DELETE VIEW view_name
B. REMOVE VIEW view_name
C. DROP VIEW view_name
D. TRUNCATE VIEW view_name

16 If you want to calculate the average salary of employees in each department, which clause is mandatory?

A. ORDER BY
B. HAVING
C. GROUP BY
D. DISTINCT

17 In Relational Algebra, what does (Rho) represent?

A. Selection
B. Projection
C. Rename
D. Division

18 Which join returns all rows when there is a match in either the left or right table, and NULLs for non-matching sides?

A. INNER JOIN
B. LEFT JOIN
C. RIGHT JOIN
D. FULL OUTER JOIN

19 Which SQL keyword is used to prevent the return of duplicate rows in a SELECT statement?

A. UNIQUE
B. DIFFERENT
C. DISTINCT
D. SINGLE

20 What will SELECT COUNT(manager_id) FROM employees return if 5 out of 100 employees have a NULL manager_id?

A. 100
B. 95
C. 5
D.

21 Which Relational Algebra operation is denoted by the symbol ?

A. Union
B. Intersection
C. Difference
D. Cartesian Product

22 Which of the following is NOT a standard SQL aggregate function?

A. AVG
B. SUM
C. MIN
D. LIMIT

23 When using the EXISTS operator in a subquery, what does the subquery return to the outer query?

A. The actual data rows found.
B. A Boolean value (True/False).
C. The count of rows found.
D. The primary keys of the rows.

24 What is the primary advantage of using a View?

A. It increases data storage size.
B. It simplifies complex queries and enhances security.
C. It allows for faster data insertion.
D. It eliminates the need for foreign keys.

25 In a NATURAL JOIN, how is the join condition determined?

A. By an explicit ON clause.
B. By an explicit USING clause.
C. Implicitly by all columns with the same name in both tables.
D. By the Primary Key of the first table.

26 Which Relational Algebra expression is equivalent to ?

A.
B.
C.
D.

27 Which option describes a 'Self Join'?

A. Joining a table with a view.
B. Joining two different tables with no relationship.
C. A table being joined with itself.
D. Joining a table with a temporary table.

28 What is the result of applying a selection ?

A. A table with only the 'Age' column.
B. A table with all columns but only rows where Age > 20.
C. A boolean value.
D. A table sorted by Age.

29 Which SQL operator is used to compare a value to a list of literal values or values returned by a subquery?

A. BETWEEN
B. LIKE
C. IN
D. IS

30 The operation that produces a relation containing all tuples in combined with all tuples in is called:

A. Cartesian Product ()
B. Natural Join ()
C. Union ()
D. Projection ()

31 When can a View be updated (INSERT/UPDATE/DELETE)?

A. Always.
B. Only if it contains aggregate functions.
C. Only if it maps directly to rows in the underlying table without aggregates or grouping.
D. Never.

32 Which logical operator represents the 'For All' condition in SQL subqueries?

A. ANY
B. SOME
C. ALL
D. EXISTS

33 If relation has tuples and relation has tuples, what is the maximum number of tuples in ?

A.
B.
C.
D.

34 Which SQL clause determines the sorting order of the result set?

A. SORT BY
B. ORDER BY
C. ALIGN BY
D. GROUP BY

35 In Relational Algebra, if and are relational expressions, then results in:

A. Tuples in or .
B. Tuples in but not in .
C. Tuples in but not in .
D. Tuples common to both.

36 What is the output of SELECT AVG(salary) FROM employees WHERE dept_id = 999 if no employees exist in department 999?

A.
B. NULL
C. Error
D. 0.00

37 Which clause is used in a View definition to ensure that data modifications through the view adhere to the view's condition?

A. WITH CHECK OPTION
B. WITH READ ONLY
C. CONSTRAINT CHECK
D. VERIFY VIEW

38 The Cartesian Product of two relations (degree ) and (degree ) has a degree of:

A.
B.
C.
D.

39 Which subquery type executes first?

A. Correlated subquery
B. Non-correlated (Simple) subquery
C. Both execute simultaneously
D. Depends on the optimizer only

40 What is the equivalent of INTERSECT using only JOIN logic?

A. INNER JOIN
B. LEFT JOIN where right is NULL
C. FULL OUTER JOIN
D. CROSS JOIN

41 Which function allows you to concatenate strings in standard SQL (or specific dialects like Oracle/Postgres)?

A. CONCAT() or ||
B. ADD()
C. MERGE()
D. LINK()

42 What is the behavior of aggregate functions with respect to duplicate values (unless DISTINCT is specified)?

A. They ignore duplicates.
B. They treat duplicates as errors.
C. They include duplicates in the calculation.
D. They average the duplicates.

43 The -join (Theta join) allows for:

A. Only equality comparisons.
B. Only inequality comparisons.
C. Any valid comparison operator () in the join predicate.
D. Joining without a condition.

44 To perform a UNION between two SQL queries, what must be true about the columns?

A. They must have different names.
B. There must be the same number of columns in the same order with similar data types.
C. They must be Primary Keys.
D. They must have the same values.

45 A subquery in the FROM clause is often referred to as:

A. Derived Table (or Inline View)
B. Scalar Subquery
C. Correlated Subquery
D. Stored Procedure

46 In Relational Algebra, what is the commutativity property of the Natural Join?

A.
B.
C.
D. Join is not commutative.

47 Which of the following creates a Cartesian product in SQL?

A. SELECT * FROM A, B
B. SELECT * FROM A JOIN B ON A.id = B.id
C. SELECT * FROM A UNION B
D. SELECT * FROM A NATURAL JOIN B

48 Which keyword is used to test whether a value matches any value in a list or subquery?

A. ANY
B. NOT
C. EXISTS
D. IS

49 In a SQL SELECT statement, in which order are the clauses logically processed?

A. SELECT, FROM, WHERE, GROUP BY
B. FROM, WHERE, GROUP BY, HAVING, SELECT
C. SELECT, GROUP BY, HAVING, WHERE
D. WHERE, FROM, SELECT, ORDER BY

50 What happens if you join a table with 5 rows to a table with 0 rows using an INNER JOIN?

A. 5 rows returned.
B. 0 rows returned.
C. NULL returned.
D. Error.