1Which 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)
Correct Answer: (Sigma)
Explanation:The selection operator, denoted by sigma (), is used to select rows (tuples) that satisfy a given predicate.
Incorrect! Try again.
2Which 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(*)
Correct Answer: COUNT(*)
Explanation:COUNT(*) returns the number of rows in a specified table, preserving duplicate rows and rows containing NULL values.
Incorrect! Try again.
3In Relational Algebra, which operator implies a combination of the Cartesian Product followed by a Selection?
A.Projection ()
B.Union ()
C.Join ()
D.Division ()
Correct Answer: Join ()
Explanation:A Theta Join or Natural Join is conceptually equivalent to performing a Cartesian Product () followed by a Selection operation () based on the join condition.
Incorrect! Try again.
4What 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
Correct Answer: 12 rows
Explanation:A CROSS JOIN produces a Cartesian product. The number of rows in the result is the product of the number of rows in the two tables ().
Incorrect! Try again.
5Which clause is used to filter the results of aggregate functions in SQL?
A.WHERE
B.HAVING
C.ORDER BY
D.GROUP BY
Correct Answer: HAVING
Explanation:The WHERE clause filters individual rows before aggregation, whereas the HAVING clause filters groups after the aggregate functions have been calculated.
Incorrect! Try again.
6Which Set Operator in SQL allows duplicates in the result set?
A.UNION
B.INTERSECT
C.UNION ALL
D.EXCEPT
Correct Answer: UNION ALL
Explanation:UNION removes duplicates from the result set, while UNION ALL combines all results from both queries, including duplicates.
Incorrect! Try again.
7In 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
Correct Answer: Select specific columns and remove duplicate tuples
Explanation:Projection () is a vertical subsetting operation that selects specified attributes (columns) and implicitly removes duplicate tuples from the result in formal relational algebra.
Incorrect! Try again.
8What 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
Correct Answer: A virtual table based on the result-set of an SQL statement
Explanation:A view is a virtual table that contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.
Incorrect! Try again.
9Which 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.
Correct Answer: It returns all records from the left table, and the matched records from the right table.
Explanation:A LEFT JOIN (or LEFT OUTER JOIN) returns all rows from the left table, with the matching rows in the right table. The result is NULL on the right side when there is no match.
Incorrect! Try again.
10Consider relations and . Which relational algebra expression represents the Natural Join?
A.
B.
C.
D.
Correct Answer:
Explanation:The symbol represents the Natural Join, which joins tuples with the same value for all common attributes.
Incorrect! Try again.
11A subquery that uses values from the outer query is called a:
A.Nested Subquery
B.Correlated Subquery
C.Scalar Subquery
D.Parallel Subquery
Correct Answer: Correlated Subquery
Explanation:A correlated subquery is a subquery that depends on the outer query for its values. It executes once for every row selected by the outer query.
Incorrect! Try again.
12Which operator is used to perform the Division operation in Relational Algebra?
A.
B.
C.
D.
Correct Answer:
Explanation:The division operator is denoted by . It is used for queries involving 'for all' (e.g., find students who have enrolled in all courses).
Incorrect! Try again.
13What 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.
Correct Answer: They must be Union Compatible.
Explanation:For Union and Set Difference, relations must be union-compatible, meaning they must have the same degree (number of columns) and the domains of corresponding attributes must be compatible.
Incorrect! Try again.
14In 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.
Correct Answer: Returns rows from the first query that are not present in the second query.
Explanation:MINUS (Oracle) or EXCEPT (SQL Server/PostgreSQL) returns distinct rows from the first result set that are not present in the second result set.
Incorrect! Try again.
15Which 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
Correct Answer: DROP VIEW view_name
Explanation:The DROP VIEW command is used to delete a view definition from the database.
Incorrect! Try again.
16If 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
Correct Answer: GROUP BY
Explanation:To calculate an aggregate (like AVG) per category (like Department), the GROUP BY clause is required to group the rows based on the department column.
Incorrect! Try again.
17In Relational Algebra, what does (Rho) represent?
A.Selection
B.Projection
C.Rename
D.Division
Correct Answer: Rename
Explanation:The Rename operator, denoted by , is used to rename the output relation or its attributes.
Incorrect! Try again.
18Which 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
Correct Answer: FULL OUTER JOIN
Explanation:A FULL OUTER JOIN combines the results of both left and right outer joins. It returns all records from both tables, filling in NULLs where matches are missing.
Incorrect! Try again.
19Which SQL keyword is used to prevent the return of duplicate rows in a SELECT statement?
A.UNIQUE
B.DIFFERENT
C.DISTINCT
D.SINGLE
Correct Answer: DISTINCT
Explanation:The DISTINCT keyword is used in a SELECT statement to return only distinct (different) values.
Incorrect! Try again.
20What 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.
Correct Answer: 95
Explanation:Aggregate functions like COUNT(column_name) ignore NULL values. Therefore, .
Incorrect! Try again.
21Which Relational Algebra operation is denoted by the symbol ?
A.Union
B.Intersection
C.Difference
D.Cartesian Product
Correct Answer: Intersection
Explanation:The Intersection operation is denoted by and returns tuples that are present in both input relations.
Incorrect! Try again.
22Which of the following is NOT a standard SQL aggregate function?
A.AVG
B.SUM
C.MIN
D.LIMIT
Correct Answer: LIMIT
Explanation:LIMIT is a clause used to specify the number of records to return, not an aggregate function that performs a calculation on a set of values.
Incorrect! Try again.
23When 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.
Correct Answer: A Boolean value (True/False).
Explanation:EXISTS returns TRUE if the subquery returns one or more records, and FALSE otherwise. It checks for the existence of rows.
Incorrect! Try again.
24What 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.
Correct Answer: It simplifies complex queries and enhances security.
Explanation:Views can encapsulate complex joins and logic, presenting a simple interface to the user. They also restrict access to specific columns or rows, enhancing security.
Incorrect! Try again.
25In 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.
Correct Answer: Implicitly by all columns with the same name in both tables.
Explanation:A Natural Join automatically joins tables based on columns with the same names and compatible data types.
Incorrect! Try again.
26Which Relational Algebra expression is equivalent to ?
A.
B.
C.
D.
Correct Answer:
Explanation: gives elements in R not in S. Subtracting this result from R leaves only the elements that were in S. Thus, .
Incorrect! Try again.
27Which 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.
Correct Answer: A table being joined with itself.
Explanation:A self join is a regular join, but the table is joined with itself. This is useful for hierarchical data (e.g., finding an employee's manager in the same table).
Incorrect! Try again.
28What 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.
Correct Answer: A table with all columns but only rows where Age > 20.
Explanation:Selection () filters rows based on a predicate. It keeps all attributes (columns) but limits the tuples (rows).
Incorrect! Try again.
29Which 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
Correct Answer: IN
Explanation:The IN operator allows you to specify multiple values in a WHERE clause, often provided by a subquery or a list.
Incorrect! Try again.
30The 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 ()
Correct Answer: Cartesian Product ()
Explanation:The Cartesian Product combines every tuple from relation R with every tuple from relation S.
Incorrect! Try again.
31When 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.
Correct Answer: Only if it maps directly to rows in the underlying table without aggregates or grouping.
Explanation:Views are generally updatable only if they are simple: no aggregates, no grouping, no distinct, and they must contain the primary keys of the underlying tables.
Incorrect! Try again.
32Which logical operator represents the 'For All' condition in SQL subqueries?
A.ANY
B.SOME
C.ALL
D.EXISTS
Correct Answer: ALL
Explanation:The ALL operator compares a value to every value in a list or returned by a subquery. For example, > ALL (...) means greater than the maximum value in the set.
Incorrect! Try again.
33If relation has tuples and relation has tuples, what is the maximum number of tuples in ?
A.
B.
C.
D.
Correct Answer:
Explanation:The maximum number of tuples occurs if and have no tuples in common (disjoint). In that case, the Union contains all tuples from both, totaling .
Incorrect! Try again.
34Which SQL clause determines the sorting order of the result set?
A.SORT BY
B.ORDER BY
C.ALIGN BY
D.GROUP BY
Correct Answer: ORDER BY
Explanation:ORDER BY is used to sort the result-set in ascending or descending order.
Incorrect! Try again.
35In 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.
Correct Answer: Tuples in but not in .
Explanation:This is the Set Difference operation. It returns tuples belonging to the first relation that are not found in the second.
Incorrect! Try again.
36What 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
Correct Answer: NULL
Explanation:If the result set is empty, aggregate functions like AVG, SUM, MAX, and MIN return NULL. COUNT returns 0.
Incorrect! Try again.
37Which 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
Correct Answer: WITH CHECK OPTION
Explanation:WITH CHECK OPTION ensures that any INSERT or UPDATE performed through the view does not create rows that would disappear from the view (i.e., fail the view's WHERE clause).
Incorrect! Try again.
38The Cartesian Product of two relations (degree ) and (degree ) has a degree of:
A.
B.
C.
D.
Correct Answer:
Explanation:The degree (number of columns/attributes) of a Cartesian product is the sum of the degrees of the individual relations.
Incorrect! Try again.
39Which subquery type executes first?
A.Correlated subquery
B.Non-correlated (Simple) subquery
C.Both execute simultaneously
D.Depends on the optimizer only
Correct Answer: Non-correlated (Simple) subquery
Explanation:A non-correlated subquery is executed once, and its result is passed to the outer query. In contrast, a correlated subquery executes repeatedly for every row of the outer query.
Incorrect! Try again.
40What 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
Correct Answer: INNER JOIN
Explanation:Conceptually, an INTERSECT returns rows common to both sets, which is similar to an INNER JOIN (though INTERSECT compares the entire tuple/row, while Join uses a condition).
Incorrect! Try again.
41Which function allows you to concatenate strings in standard SQL (or specific dialects like Oracle/Postgres)?
A.CONCAT() or ||
B.ADD()
C.MERGE()
D.LINK()
Correct Answer: CONCAT() or ||
Explanation:The || operator (standard SQL) or CONCAT() function is used to join two or more strings together.
Incorrect! Try again.
42What 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.
Correct Answer: They include duplicates in the calculation.
Explanation:By default (e.g., SUM(salary)), all values including duplicates are processed. SUM(DISTINCT salary) would ignore duplicates.
Incorrect! Try again.
43The -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.
Correct Answer: Any valid comparison operator () in the join predicate.
Explanation:A Theta join is a generalization of the natural join where the join condition is denoted by , which can be any comparison operator.
Incorrect! Try again.
44To 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.
Correct Answer: There must be the same number of columns in the same order with similar data types.
Explanation:This is the requirement for union-compatibility in SQL set operations.
Incorrect! Try again.
45A 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
Correct Answer: Derived Table (or Inline View)
Explanation:When a subquery is placed in the FROM clause, it acts as a temporary table for the duration of the query, often called a Derived Table.
Incorrect! Try again.
46In Relational Algebra, what is the commutativity property of the Natural Join?
A.
B.
C.
D.Join is not commutative.
Correct Answer:
Explanation:The Natural Join is commutative; the order of relations does not affect the resulting set of tuples (though column order might vary in implementation, logically they are the same set).
Incorrect! Try again.
47Which 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
Correct Answer: SELECT * FROM A, B
Explanation:Listing tables in the FROM clause without a WHERE or JOIN condition results in a Cross Join (Cartesian Product).
Incorrect! Try again.
48Which keyword is used to test whether a value matches any value in a list or subquery?
A.ANY
B.NOT
C.EXISTS
D.IS
Correct Answer: ANY
Explanation:The ANY (or SOME) operator returns true if the comparison returns true for at least one of the values in the list/subquery.
Incorrect! Try again.
49In 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
Correct Answer: FROM, WHERE, GROUP BY, HAVING, SELECT
Explanation:Logically, the database first identifies the tables (FROM), filters rows (WHERE), groups them (GROUP BY), filters groups (HAVING), and finally projects the columns (SELECT).
Incorrect! Try again.
50What 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.
Correct Answer: 0 rows returned.
Explanation:An Inner Join requires a match in both tables. Since one table is empty, no matches are possible, resulting in 0 rows.
Incorrect! Try again.
Give Feedback
Help us improve by sharing your thoughts or reporting issues.