1Which of the following is an aggregate function used to find the total number of rows in a dataset?
Aggregate functions
Easy
A.SUM()
B.COUNT()
C.MAX()
D.TOTAL()
Correct Answer: COUNT()
Explanation:
The COUNT() function is a standard SQL aggregate function that returns the number of rows that match a specified criterion.
Incorrect! Try again.
2Which SQL clause is typically used alongside aggregate functions to arrange identical data into groups?
Aggregate functions
Easy
A.WHERE
B.ORDER BY
C.HAVING
D.GROUP BY
Correct Answer: GROUP BY
Explanation:
The GROUP BY clause groups rows that have the same values into summary rows, allowing aggregate functions to be applied to each group.
Incorrect! Try again.
3Which type of SQL join returns only the rows that have matching values in both tables?
Sql joins
Easy
A.FULL OUTER JOIN
B.INNER JOIN
C.RIGHT OUTER JOIN
D.LEFT OUTER JOIN
Correct Answer: INNER JOIN
Explanation:
An INNER JOIN selects records that have matching values in both tables being joined. If there is no match, the row is excluded.
Incorrect! Try again.
4Which join returns all rows from both tables, matching records where possible and filling in NULLs where there is no match?
Sql joins
Easy
A.CROSS JOIN
B.FULL OUTER JOIN
C.LEFT JOIN
D.INNER JOIN
Correct Answer: FULL OUTER JOIN
Explanation:
A FULL OUTER JOIN combines the results of both left and right outer joins, returning all (matched or unmatched) rows from the tables on both sides.
Incorrect! Try again.
5Which set operator combines the results of two queries and automatically removes duplicate rows?
set operators
Easy
A.UNION
B.EXCEPT
C.UNION ALL
D.INTERSECT
Correct Answer: UNION
Explanation:
The UNION operator combines the result sets of two or more SELECT statements into a single result set and removes duplicate rows. To keep duplicates, UNION ALL is used.
Incorrect! Try again.
6Which set operator returns only the distinct rows that are present in the results of both queries?
set operators
Easy
A.UNION
B.EXCEPT
C.INTERSECT
D.MINUS
Correct Answer: INTERSECT
Explanation:
The INTERSECT operator compares the result sets of two queries and returns only the rows that are output by both queries.
Incorrect! Try again.
7What is a database view?
views
Easy
A.An index used to speed up queries
B.A physical table storing redundant data
C.A primary key constraint
D.A virtual table based on the result-set of an SQL statement
Correct Answer: A virtual table based on the result-set of an SQL statement
Explanation:
A view is a virtual table whose contents are defined by a query. It does not store data itself but displays data stored in other tables.
Incorrect! Try again.
8Which SQL command is used to remove a view from the database?
views
Easy
A.TRUNCATE VIEW
B.DELETE VIEW
C.DROP VIEW
D.REMOVE VIEW
Correct Answer: DROP VIEW
Explanation:
The DROP VIEW command completely removes the definition of a view from the database schema.
Incorrect! Try again.
9What is a subquery in SQL?
subqueries
Easy
A.A query that uses only aggregate functions
B.A query nested inside another query
C.A query that creates a new database
D.A query that joins three or more tables
Correct Answer: A query nested inside another query
Explanation:
A subquery (or inner query) is a query placed within another SQL query (such as a SELECT, INSERT, UPDATE, or DELETE statement).
Incorrect! Try again.
10Which SQL operator is commonly used in the WHERE clause to check if a value matches any value returned by a subquery?
subqueries
Easy
A.LIKE
B.IS NULL
C.BETWEEN
D.IN
Correct Answer: IN
Explanation:
The IN operator allows you to specify multiple values in a WHERE clause and is frequently used to compare a column against a list of values returned by a subquery.
Incorrect! Try again.
11In relational algebra, which operation is used to extract specific rows from a relation based on a given condition?
relational algebra
Easy
A.Projection ()
B.Cross Product ()
C.Selection ()
D.Join ()
Correct Answer: Selection ()
Explanation:
The Selection operation, denoted by sigma (), is a unary operation used to select a subset of tuples (rows) from a relation that satisfy a selection condition.
Incorrect! Try again.
12Which relational algebra operation is used to extract specified columns from a relation?
relational algebra
Easy
A.Projection ()
B.Intersection ()
C.Selection ()
D.Union ()
Correct Answer: Projection ()
Explanation:
The Projection operation, denoted by pi (), creates a new relation containing only the specified attributes (columns) from the original relation.
Incorrect! Try again.
13Which SQL clause is mandatory when defining a window function to specify the partitioning and ordering of the window?
Window functions
Easy
A.HAVING
B.PARTITION OF
C.OVER()
D.GROUP BY
Correct Answer: OVER()
Explanation:
The OVER() clause is required for window functions. It defines the window or user-specified set of rows over which the window function operates.
Incorrect! Try again.
14Which window function assigns a unique sequential integer to each row within a partition of a result set?
Window functions
Easy
A.NTILE()
B.ROW_NUMBER()
C.DENSE_RANK()
D.RANK()
Correct Answer: ROW_NUMBER()
Explanation:
The ROW_NUMBER() function assigns a distinct, sequential integer starting from 1 to each row within its partition, regardless of duplicate values.
Incorrect! Try again.
15What is the primary purpose of a hash function in a database context?
Hashing
Easy
A.To join multiple tables together
B.To create temporary virtual tables
C.To map search keys to specific bucket or block addresses
D.To sort data alphabetically in tables
Correct Answer: To map search keys to specific bucket or block addresses
Explanation:
A hash function takes a search key and computes a hash value, which directly maps to a specific bucket address where the corresponding record is stored.
Incorrect! Try again.
16What is it called when a hash function generates the same bucket address for two different search keys?
Hashing
Easy
A.A deadlock
B.A syntax error
C.A query optimization
D.A hash collision
Correct Answer: A hash collision
Explanation:
A hash collision occurs when two or more distinct inputs to a hash function produce the same output (bucket address), requiring collision resolution techniques.
Incorrect! Try again.
17What is the primary benefit of creating an index on a database table?
Indexing
Easy
A.It eliminates the need for primary keys
B.It automatically encrypts the data
C.It speeds up data retrieval operations
D.It reduces the total storage space required
Correct Answer: It speeds up data retrieval operations
Explanation:
Indexes are special lookup tables that the database search engine can use to speed up data retrieval. Simply put, an index acts like a pointer to data in a table.
Incorrect! Try again.
18Which data structure is most commonly used to implement indexing in a modern relational database system?
Indexing
Easy
A.Stack
B.Queue
C.Linked List
D.B-Tree (and its variants like B+ Tree)
Correct Answer: B-Tree (and its variants like B+ Tree)
Explanation:
B-Trees (specifically B+ Trees) are the most common data structure for database indexes because they remain balanced and offer efficient insertion, deletion, and search times.
Incorrect! Try again.
19What is the primary role of a query optimizer in a Database Management System?
Query Optimization
Easy
A.To enforce referential integrity constraints
B.To determine the most efficient execution plan for a given query
C.To write SQL queries automatically for the user
D.To manage concurrent transactions
Correct Answer: To determine the most efficient execution plan for a given query
Explanation:
The query optimizer evaluates multiple ways to execute a query (different execution plans) and selects the one that is estimated to run the fastest and use the fewest resources.
Incorrect! Try again.
20Which type of query optimizer relies on database statistics (such as table size and data distribution) to evaluate alternative execution plans?
Query Optimization
Easy
A.Buffer-based optimizer
B.Rule-based optimizer
C.Cost-based optimizer
D.Syntax-based optimizer
Correct Answer: Cost-based optimizer
Explanation:
A cost-based optimizer uses metadata and statistics about tables, indexes, and data distribution to estimate the processing cost of different execution plans and chooses the cheapest one.
Incorrect! Try again.
21Consider a table Sales(Region, Amount). Which query correctly finds the regions where the average sales amount exceeds 500?
Aggregate functions
Medium
A.SELECT Region FROM Sales WHERE AVG(Amount) > 500 GROUP BY Region
B.SELECT Region FROM Sales GROUP BY Region HAVING AVG(Amount) > 500
C.SELECT Region FROM Sales GROUP BY Region WHERE AVG(Amount) > 500
D.SELECT Region FROM Sales HAVING AVG(Amount) > 500
Correct Answer: SELECT Region FROM Sales GROUP BY Region HAVING AVG(Amount) > 500
Explanation:
The HAVING clause is used to filter groups created by the GROUP BY clause. The WHERE clause cannot be used with aggregate functions directly, as it filters rows before grouping.
Incorrect! Try again.
22If a column Bonus contains the values [100, NULL, 200, 300, NULL], what will be the result of SELECT COUNT(Bonus), SUM(Bonus) FROM Employee?
Aggregate functions
Medium
A.5, 600
B.5, NULL
C.3, 600
D.3, NULL
Correct Answer: 3, 600
Explanation:
Aggregate functions like COUNT() and SUM() ignore NULL values. COUNT(Bonus) counts the 3 non-null values, and SUM(Bonus) adds them to get 600.
Incorrect! Try again.
23You need to find all customers, including those who have not placed any orders, along with their order details. Which type of join should be used between the Customers (left) and Orders (right) tables?
Sql joins
Medium
A.RIGHT OUTER JOIN
B.NATURAL JOIN
C.INNER JOIN
D.LEFT OUTER JOIN
Correct Answer: LEFT OUTER JOIN
Explanation:
A LEFT OUTER JOIN returns all records from the left table (Customers), and the matched records from the right table (Orders). If there is no match, the result is NULL on the right side.
Incorrect! Try again.
24What is the primary purpose of a Self Join in SQL?
Sql joins
Medium
A.To join a table to itself to compare rows within the same table.
B.To automatically eliminate duplicate records from a table.
C.To combine rows from two different tables based on a related column.
D.To return the Cartesian product of two identical tables.
Correct Answer: To join a table to itself to compare rows within the same table.
Explanation:
A self join is a regular join where a table is joined with itself. It is commonly used for hierarchical data or comparing rows within the same table, such as finding employees who earn more than their managers.
Incorrect! Try again.
25When combining the results of two queries, what is the key difference between UNION and UNION ALL?
set operators
Medium
A.UNION only works with numeric data types.
B.UNION ALL automatically sorts the output, whereas UNION does not.
C.UNION removes duplicates, making it generally slower than UNION ALL.
D.UNION ALL removes duplicates, making it slower than UNION.
Correct Answer: UNION removes duplicates, making it generally slower than UNION ALL.
Explanation:
UNION performs an internal sort/hash to remove duplicate rows from the combined result set, causing overhead. UNION ALL appends the results directly, keeping duplicates and running faster.
Incorrect! Try again.
26Which SQL set operator is equivalent to the relational algebra set difference operation?
set operators
Medium
A.EXCEPT
B.UNION
C.INTERSECT
D.CROSS JOIN
Correct Answer: EXCEPT
Explanation:
The EXCEPT (or MINUS in some dialects) operator returns the distinct rows from the first query that are not present in the results of the second query, which is mathematically equivalent to set difference.
Incorrect! Try again.
27Under which of the following conditions is a standard SQL view generally NOT updatable?
views
Medium
A.When the view contains a simple SELECT from a single table.
B.When the view contains a GROUP BY clause or aggregate functions.
C.When the view excludes some columns of the base table.
D.When the view is created with the WITH CHECK OPTION clause.
Correct Answer: When the view contains a GROUP BY clause or aggregate functions.
Explanation:
Views are generally not updatable if they contain aggregate functions, GROUP BY, DISTINCT, or set operations, because the database cannot unambiguously map the updated view row back to a specific row in the base table.
Incorrect! Try again.
28What is a Materialized View?
views
Medium
A.A system-level view that restricts users from executing DML statements.
B.A view that temporarily holds data only during an active user session.
C.A physical copy of the query results stored on disk to improve read performance.
D.A virtual table whose contents are generated dynamically at runtime every time it is queried.
Correct Answer: A physical copy of the query results stored on disk to improve read performance.
Explanation:
Unlike standard views which are virtual, materialized views store the actual data of the query result physically on the disk. They are used to speed up complex queries by precomputing the results.
Incorrect! Try again.
29How does a correlated subquery differ from a non-correlated subquery?
subqueries
Medium
A.A correlated subquery is faster because it does not depend on the outer query.
B.A correlated subquery can only be used in the FROM clause.
C.A correlated subquery executes exactly once and passes its result to the outer query.
D.A correlated subquery references columns from the outer query and must be evaluated for each row of the outer query.
Correct Answer: A correlated subquery references columns from the outer query and must be evaluated for each row of the outer query.
Explanation:
A correlated subquery contains a reference to a table in the outer query. Therefore, it cannot be evaluated independently and must run iteratively for every row processed by the outer query.
Incorrect! Try again.
30Which keyword is used to test whether a subquery returns any rows at all, evaluating to TRUE if at least one row is returned?
subqueries
Medium
A.ANY
B.ALL
C.IN
D.EXISTS
Correct Answer: EXISTS
Explanation:
The EXISTS operator is used to test for the existence of any record in a subquery. It returns true if the subquery returns one or more records.
Incorrect! Try again.
31In relational algebra, if you want to find the names of employees who work on ALL projects, which operation is most appropriate?
relational algebra
Medium
A.Division ()
B.Selection ()
C.Projection ()
D.Cartesian Product ()
Correct Answer: Division ()
Explanation:
The division operator is specifically designed to answer queries involving "for all" conditions, such as finding entities in one relation that match with all entities in another relation.
Incorrect! Try again.
32Which relational algebra operation is logically equivalent to performing a Cartesian product followed by a Selection operation?
relational algebra
Medium
A.Theta Join ()
B.Natural Join ()
C.Set Difference ()
D.Intersection ()
Correct Answer: Theta Join ()
Explanation:
A Theta Join combines a Cartesian product of two relations with a selection condition (). It joins tuples that satisfy the specified condition.
Incorrect! Try again.
33If two employees have the same highest salary, how will the RANK() and DENSE_RANK() functions assign ranks to the employee with the next highest salary?
Window functions
Medium
A.RANK() assigns 2, while DENSE_RANK() assigns 3.
B.Both will assign rank 3.
C.Both will assign rank 2.
D.RANK() assigns 3, while DENSE_RANK() assigns 2.
Correct Answer: RANK() assigns 3, while DENSE_RANK() assigns 2.
Explanation:
Both employees tied for the highest salary receive rank 1. RANK() will skip the next rank (leaving a gap) and assign 3 to the next person. DENSE_RANK() does not leave gaps and will assign 2.
Incorrect! Try again.
34In a window function, what is the purpose of the PARTITION BY clause?
Window functions
Medium
A.To sort the entire result set in descending order.
B.To physically partition the database tables across multiple disks.
C.To filter rows before the window function is applied.
D.To divide the result set into discrete groups over which the window function is applied.
Correct Answer: To divide the result set into discrete groups over which the window function is applied.
Explanation:
PARTITION BY divides the data into partitions or groups. The window function is then applied to each partition separately and restarts its calculation for each new partition.
Incorrect! Try again.
35In a static hashing scheme, what is a common technique used to handle hash collisions where multiple keys map to the same bucket?
Hashing
Medium
A.Using overflow buckets (chaining)
B.Creating a new hash table and rehashing all entries
C.Deleting the older record to accommodate the new one
D.Linear probing only
Correct Answer: Using overflow buckets (chaining)
Explanation:
In static hashing, when a bucket is full and a collision occurs, overflow buckets are created and linked together using pointers (chaining) to hold the extra records.
Incorrect! Try again.
36Which of the following is a characteristic of Extendible Hashing?
Hashing
Medium
A.It guarantees that all data retrieval will always take time.
B.It relies entirely on overflow chains to handle all collisions.
C.It uses a fixed number of buckets that cannot be changed.
D.It uses a directory of pointers that doubles in size when a bucket overflows.
Correct Answer: It uses a directory of pointers that doubles in size when a bucket overflows.
Explanation:
Extendible hashing is a dynamic hashing technique that uses a directory structure. When a bucket overflows, the directory size can double, allowing the hash structure to grow gracefully without requiring a complete rehash.
Incorrect! Try again.
37Why is a B+ tree generally preferred over a standard B-tree for database indexing?
Indexing
Medium
A.B+ trees only store keys in internal nodes, and all leaf nodes are linked, optimizing range queries.
B.B+ trees use hash functions internally to locate records in time.
C.B+ trees allow faster insertion times because they do not require balancing.
D.B+ trees store data pointers in internal nodes, saving space.
Correct Answer: B+ trees only store keys in internal nodes, and all leaf nodes are linked, optimizing range queries.
Explanation:
In a B+ tree, all data records are stored at the leaf level, and the leaf nodes form a linked list. This makes sequential access and range queries highly efficient compared to standard B-trees.
Incorrect! Try again.
38What defines a Clustered Index in a relational database?
Indexing
Medium
A.A table can have multiple clustered indexes created on different columns.
B.It is an index that stores data records in an unordered heap file.
C.It uses a hash table structure rather than a tree structure.
D.It determines the physical sort order of the data rows in the table.
Correct Answer: It determines the physical sort order of the data rows in the table.
Explanation:
A clustered index alters the way records are physically stored on the disk, sorting them based on the indexed column. Because data can only be sorted in one physical order, a table can only have one clustered index.
Incorrect! Try again.
39During query optimization, a common heuristic rule is to "push down" selections in the relational algebra tree. What is the primary benefit of this technique?
Query Optimization
Medium
A.It reduces the size of intermediate relations before costly operations like joins are performed.
B.It converts all inner joins to outer joins.
C.It reduces the number of columns in the final result.
D.It bypasses the need for using database indexes.
Correct Answer: It reduces the size of intermediate relations before costly operations like joins are performed.
Explanation:
Pushing selection operations down the query execution tree filters out unnecessary rows as early as possible. This minimizes the volume of data that must be processed in subsequent expensive operations like joins.
Incorrect! Try again.
40In cost-based query optimization, what metadata is heavily relied upon by the optimizer to choose the most efficient execution plan?
Query Optimization
Medium
A.The amount of free space remaining on the hard drive.
B.The specific names of the primary key columns.
C.The order in which the SQL query clauses are written by the developer.
D.Database statistics such as table sizes, tuple counts, and index distributions.
Correct Answer: Database statistics such as table sizes, tuple counts, and index distributions.
Explanation:
A cost-based optimizer uses metadata statistics (like the number of tuples, block size, and distribution of data in indexes) to estimate the resource cost of different execution plans and selects the one with the lowest cost.
Incorrect! Try again.
41In standard SQL, consider a table Employee with columns DeptID and Bonus. DeptID has values (1, 1, NULL, NULL). Bonus has values (100, 200, 300, 400). What is the output of SELECT DeptID, SUM(Bonus) FROM Employee GROUP BY DeptID; regarding the NULL DeptIDs?
Aggregate functions
Hard
A.They produce two separate rows with DeptID as NULL, having sums 300 and 400 respectively.
B.They are ignored and omitted from the result set entirely.
C.The query throws a syntax error because NULL cannot be used in a GROUP BY clause.
D.They are grouped into a single row with a DeptID of NULL and a sum of 700.
Correct Answer: They are grouped into a single row with a DeptID of NULL and a sum of 700.
Explanation:
In standard SQL, the GROUP BY clause treats multiple NULL values as equivalent for the purpose of grouping. Therefore, all rows with a NULL DeptID are placed into a single group, and their aggregate functions are computed together.
Incorrect! Try again.
42Which of the following statements about aggregate functions is TRUE when evaluated over an empty set (0 rows)?
When an aggregate function processes an empty set, COUNT inherently returns 0 because there are zero items to count. However, other aggregates like SUM, MAX, MIN, and AVG return NULL to indicate the absence of data to compute.
Incorrect! Try again.
43Consider tables A (id, val) and B (id, val). What is the semantic difference between SELECT * FROM A LEFT JOIN B ON A.id = B.id AND B.val > 10 and SELECT * FROM A LEFT JOIN B ON A.id = B.id WHERE B.val > 10?
Sql joins
Hard
A.The WHERE clause condition acts after the join, effectively converting the LEFT JOIN into an INNER JOIN.
B.They produce identical results and query execution plans.
C.The ON clause throws an error because filtering conditions must be placed in the WHERE clause.
D.The ON clause condition applies the filter to table A as well, eliminating rows from A before the join.
Correct Answer: The WHERE clause condition acts after the join, effectively converting the LEFT JOIN into an INNER JOIN.
Explanation:
In a LEFT JOIN, an ON clause condition determines which rows from the right table match; non-matching rows still yield the left table's row with NULLs. If the condition is in the WHERE clause, it filters the final result set. Since NULL > 10 evaluates to UNKNOWN (effectively false), the unmatched rows are discarded, acting like an INNER JOIN.
Incorrect! Try again.
44Can a self non-equi join be used on a table Matches (Team, Score) to strictly find teams that scored higher than the average score of all teams without utilizing subqueries, window functions, or explicit aggregate functions?
Sql joins
Hard
A.Yes, by joining the table with itself on inequality conditions.
B.No, because self-joins only support equi-join (=) conditions.
C.Yes, by using a CROSS JOIN combined with a WHERE clause.
D.No, because calculating an average inherently requires aggregation over a set.
Correct Answer: No, because calculating an average inherently requires aggregation over a set.
Explanation:
Relational joins compare scalar values between pairs of rows. Finding an average involves calculating an aggregate across the entire domain, which cannot be derived purely through scalar tuple-to-tuple comparisons in a join operation.
Incorrect! Try again.
45Given standard SQL precedence rules, how is the expression SELECT * FROM R UNION SELECT * FROM S INTERSECT SELECT * FROM T EXCEPT SELECT * FROM U evaluated?
Set operators
Hard
A.INTERSECT first: (R UNION (S INTERSECT T)) EXCEPT U
B.UNION and EXCEPT have higher precedence than INTERSECT
C.EXCEPT first: R UNION (S INTERSECT (T EXCEPT U))
D.Left to right: (((R UNION S) INTERSECT T) EXCEPT U)
Correct Answer: INTERSECT first: (R UNION (S INTERSECT T)) EXCEPT U
Explanation:
In standard SQL, INTERSECT has a higher precedence than UNION and EXCEPT. UNION and EXCEPT generally share the same precedence and are evaluated left-to-right.
Incorrect! Try again.
46Let bag and bag . What is the cardinality of the result of the bag difference ?
Set operators
Hard
A.2
B.3
C.4
D.1
Correct Answer: 2
Explanation:
The EXCEPT ALL operator respects bag semantics. contains three '1's and contains two '1's, so the result has '1'. has two '2's and has one '2', leaving '2'. The result is , which has a cardinality of 2.
Incorrect! Try again.
47View V1 is created as SELECT * FROM T WHERE A > 10. View V2 is created as SELECT * FROM V1 WHERE A < 20 WITH LOCAL CHECK OPTION. If a user attempts to insert a row with A = 5 through V2, what happens in a standard SQL compliant database?
Views
Hard
A.Insertion succeeds because LOCAL CHECK OPTION only enforces V2's condition () and ignores V1 since V1 lacks a check option.
B.Insertion fails because LOCAL CHECK OPTION inherently checks all underlying view conditions regardless of how they were defined.
C.Insertion fails because the base table T restricts all inserts that do not satisfy .
D.Insertion succeeds but replaces the value 5 with a NULL.
Correct Answer: Insertion succeeds because LOCAL CHECK OPTION only enforces V2's condition () and ignores V1 since V1 lacks a check option.
Explanation:
WITH LOCAL CHECK OPTION enforces the condition of the view it is defined on and cascades to underlying views only if those underlying views also have a check option. Since V1 does not have a check option, the condition A > 10 is not enforced during this insert, allowing A = 5 to pass.
Incorrect! Try again.
48Which of the following view definitions is generally considered automatically updatable in standard SQL?
Views
Hard
A.A view containing a derived table in the FROM clause.
B.A view built on a single base table without GROUP BY, aggregate functions, or distinct constraints.
C.A view utilizing the DISTINCT keyword.
D.A view defined using a set operator like UNION.
Correct Answer: A view built on a single base table without GROUP BY, aggregate functions, or distinct constraints.
Explanation:
For a view to be automatically updatable, the database must be able to unambiguously map the view's rows back to the base table. Constructs like DISTINCT, GROUP BY, aggregations, and set operators break this 1:1 mapping.
Incorrect! Try again.
49What is the critical risk of evaluating SELECT * FROM A WHERE A.id NOT IN (SELECT B.id FROM B) if table B contains at least one NULL value in the id column?
Subqueries
Hard
A.The subquery will throw a runtime syntax error.
B.The NULL value is bypassed, and the query successfully filters out only the non-NULL matches.
C.The query will return an empty set (0 rows) regardless of the values in table A.
D.The query will return all rows from table A, effectively ignoring the NOT IN clause.
Correct Answer: The query will return an empty set (0 rows) regardless of the values in table A.
Explanation:
The NOT IN clause is equivalent to id != val1 AND id != val2 AND .... If any value in the subquery is NULL, id != NULL evaluates to UNKNOWN. Because UNKNOWN combined with AND can never be TRUE, the WHERE condition fails for every row in table A.
Incorrect! Try again.
50Which specific type of subquery inherently forces a dependency on the outer query, often preventing the optimizer from evaluating it independently as a one-time operation?
Subqueries
Hard
A.Correlated subquery
B.Uncorrelated subquery
C.Derived table subquery
D.Scalar subquery
Correct Answer: Correlated subquery
Explanation:
A correlated subquery references columns from the outer query. This dependency means the inner query relies on values from the current row being processed in the outer query, preventing independent execution.
Incorrect! Try again.
51The relational division operator can be expressed using fundamental relational algebra operators. Which formula correctly expresses , assuming schemas and ?
Relational algebra
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Division finds all in associated with every in . gets all candidate 's. generates all possible ideal combinations. Subtracting gives combinations missing from . Projecting from this yields disqualified 's. Subtracting these from the original candidates gives the correct result.
Incorrect! Try again.
52If relation has schema and relation has schema , what is the result of the natural join if relations and have zero common tuple values for their shared attribute ?
Relational algebra
Hard
A.A Cartesian product of and .
B.An execution error due to disjoint domains.
C.A left outer join equivalent relation containing NULLs.
D.An empty relation with schema .
Correct Answer: An empty relation with schema .
Explanation:
A natural join enforces an equality condition on identically named attributes. If there are no matching values for attribute between and , no tuples satisfy the join condition, resulting in an empty set with the combined schema.
Incorrect! Try again.
53Which of the following identities correctly describes the equivalence of relational algebra operations?
Relational algebra
Hard
A.The natural join operator () is not commutative.
B. under all conditions.
C.
D.The cross product of and yields a relation with cardinality .
Correct Answer:
Explanation:
A fundamental optimization equivalence rule in relational algebra dictates that a selection operation with a conjunctive condition () can be cascaded into a sequence of individual selection operations.
Incorrect! Try again.
54In the standard SQL window frame clause ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, what is the default framing behavior if the ORDER BY clause within the OVER() function is completely omitted?
Window functions
Hard
A.It evaluates the window function over the entire partition, effectively treating it as ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.
B.It automatically orders the partition by the primary key.
C.It evaluates strictly up to the current row based on a non-deterministic internal read order.
D.It throws a syntax error because a frame clause requires an explicit ORDER BY.
Correct Answer: It evaluates the window function over the entire partition, effectively treating it as ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.
Explanation:
According to the SQL standard, if the ORDER BY clause is omitted in an OVER() clause, the default frame encompasses the entire partition, ignoring the physical ordering for running totals.
Incorrect! Try again.
55Given a table containing a score column with values: 100, 100, 90, 80. Using the window function DENSE_RANK() OVER (ORDER BY score DESC), what integer rank is assigned to the row with the score 90?
Window functions
Hard
A.3
B.1
C.2
D.4
Correct Answer: 2
Explanation:
DENSE_RANK() does not leave gaps in ranking values when there are ties. The two 100 scores share rank 1. The immediate next distinct value (90) gets the sequential rank of 2.
Incorrect! Try again.
56Why does standard SQL prohibit the usage of Window functions directly inside the WHERE and HAVING clauses of a query?
Window functions
Hard
A.Because they return multiple rows for a single scalar filter condition.
C.Because window functions are logically evaluated after the WHERE and HAVING clauses have already determined the result set.
D.Because they require an explicit GROUP BY clause to function.
Correct Answer: Because window functions are logically evaluated after the WHERE and HAVING clauses have already determined the result set.
Explanation:
SQL's logical order of operations processes WHERE and HAVING before evaluating window functions. To filter on a window function's result, the window function must be computed first, typically inside a CTE or derived table.
Incorrect! Try again.
57In the context of Extendible Hashing, a directory doubling operation is specifically triggered during key insertion when:
Hashing
Hard
A.The primary bucket becomes full and a secondary overflow chain cannot be allocated.
B.The global depth strictly exceeds the local depth of the overflowing bucket.
C.The local depth of the overflowing bucket equals the current global depth.
D.The overall load factor of the hash table surpasses a predefined threshold.
Correct Answer: The local depth of the overflowing bucket equals the current global depth.
Explanation:
When a bucket overflows, its local depth is compared to the directory's global depth. If they are equal, the directory does not have enough bits to represent a split, thereby forcing the directory to double in size and the global depth to increment.
Incorrect! Try again.
58In a tree of order (where represents the maximum number of block pointers per node), what is the minimum number of keys a non-root internal node must contain?
Indexing
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
A non-root internal node in a tree of order must have at least pointers to children. Because the number of keys is always one less than the number of pointers, the minimum number of keys is .
Incorrect! Try again.
59In heuristic query optimization, what is the primary structural reason for pushing selection () operators down the algebraic query tree as early as possible?
Query Optimization
Hard
A.To maximize the utilization of clustered and covering indexes at the leaf level.
B.To eliminate the requirement for sorting operations at the root node.
D.To reduce the cardinality of intermediate relations prior to executing expensive binary operations like joins.
Correct Answer: To reduce the cardinality of intermediate relations prior to executing expensive binary operations like joins.
Explanation:
Applying selections early removes disqualified tuples from the pipeline. This drastically shrinks the size of intermediate tables, thereby reducing memory and CPU overhead for computationally heavy operations like joins that appear higher up in the tree.
Incorrect! Try again.
60The System R query optimizer pioneered the use of dynamic programming for determining the optimal join order. For a query joining tables, what is the time complexity of this join enumeration algorithm if it strictly restricts its search space to left-deep trees?
Query Optimization
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
By limiting the search space to left-deep trees, the System R dynamic programming algorithm builds optimal plans for subsets of relations. The number of non-empty subsets of relations is , yielding a time and space complexity proportional to , significantly better than the brute force permutation bound.