Courseiva

CCNA Database Structures And SQL Questions

59 questions · Database Structures And SQL · All types, answers revealed

1
MCQhard

A developer needs to ensure that a 'Customer_ID' field in a 'Orders' table always references a valid ID in the 'Customers' table. Which constraint should be applied?

A.PRIMARY KEY
B.UNIQUE
C.CHECK
D.FOREIGN KEY
AnswerD

A FOREIGN KEY enforces referential integrity by requiring every Customer_ID value in Orders to match an existing primary key in Customers, rejecting inserts or updates that reference a non-existent customer. This directly satisfies the stem's requirement that the field always reference a valid ID.

Why this answer

A FOREIGN KEY constraint is used to enforce referential integrity between two tables. It ensures that the Customer_ID in the Orders table matches an existing ID in the Customers table, preventing orphaned records and maintaining consistent relationships.

Exam trap

DS0-001 often tests the confusion between PRIMARY KEY (uniqueness within a table) and FOREIGN KEY (referential integrity across tables), catching candidates who overlook the cross-table requirement.

How to eliminate wrong answers

Option A is wrong because a PRIMARY KEY uniquely identifies each row in its own table and cannot reference another table. Option B is wrong because a UNIQUE constraint ensures uniqueness within a single table but does not enforce cross-table references. Option C is wrong because a CHECK constraint validates data against a logical expression (e.g., range or format) but cannot reference another table's data.

2
MCQhard

A database administrator is designing a schema for a financial application that must enforce that every account balance is never negative. The application inserts and updates balances frequently, and the DBA wants the rule enforced at the database level regardless of which application or script performs the change. Which database object should the DBA create to enforce this rule?

A.A stored procedure that all applications must call to modify balances.
B.A foreign key constraint referencing a Balances lookup table that contains only non-negative values.
C.A CHECK constraint on the Balance column that verifies Balance >= 0.
D.A trigger on the table that rolls back any transaction resulting in a negative balance.
AnswerC

A CHECK constraint is a declarative database object that validates data on every INSERT and UPDATE, regardless of the client. Defining Balance >= 0 ensures the rule is enforced at the storage engine level, cannot be bypassed by application code, and applies uniformly to all statements. This is the standard, most efficient way to enforce a simple domain rule like non-negative balances.

Why this answer

A CHECK constraint is the appropriate database object because it declaratively enforces a Boolean condition on column values during every INSERT and UPDATE. It cannot be bypassed by applications or ad-hoc scripts, and the database engine optimizes its evaluation. Stored procedures and triggers can enforce rules procedurally but are more complex and, in the case of stored procedures, easily bypassed.

A foreign key addresses referential integrity, not numeric ranges.

Exam trap

The trap here is choosing a trigger or stored procedure for a simple domain rule, overlooking that a declarative CHECK constraint enforces the condition universally with less overhead.

3
MCQeasy

Which SQL statement is used to remove a table entirely from the database?

A.DELETE TABLE
B.REMOVE TABLE
C.TRUNCATE TABLE
D.DROP TABLE
AnswerD

DROP TABLE deletes the table's definition and all its data, removing the object from the schema entirely. This satisfies the stem's requirement to remove the table itself, unlike DELETE, which removes rows while preserving the table structure, or TRUNCATE, which empties data but keeps the table.

Why this answer

The SQL statement used to remove a table entirely from the database is DROP TABLE. This command deletes the table definition, all data, and associated indexes, triggers, and permissions. It is a Data Definition Language (DDL) operation and cannot be rolled back in most databases once committed.

Exam trap

DS0-001 often tests the difference between DROP, DELETE, and TRUNCATE, causing candidates to confuse the removal of data with the removal of the table structure.

How to eliminate wrong answers

Option A is wrong because DELETE TABLE is not valid SQL syntax; DELETE is used to remove rows from a table, not the table itself. Option B is wrong because REMOVE TABLE is not a valid SQL command. Option C is wrong because TRUNCATE TABLE removes all rows from a table but leaves the table structure intact for future use.

4
MCQhard

A database administrator is designing a table to store product inventory. The table must enforce that each product has a unique SKU and that the quantity_on_hand column never drops below zero. The administrator adds a PRIMARY KEY constraint on SKU and a CHECK constraint on quantity_on_hand. A developer then tries to insert a row with a NULL SKU and a negative quantity. Which statement describes the outcome?

A.The insert succeeds because CHECK constraints are evaluated only on UPDATE, not INSERT.
B.The insert fails only because of the negative quantity; the NULL SKU is allowed because PRIMARY KEY does not enforce NOT NULL.
C.The insert fails because the PRIMARY KEY constraint rejects NULL values, and the CHECK constraint rejects negative values.
D.The insert succeeds with a warning because NULL values bypass PRIMARY KEY enforcement.
AnswerC

A PRIMARY KEY constraint implicitly includes NOT NULL, so a NULL SKU is rejected. Separately, the CHECK constraint on quantity_on_hand rejects the negative value. Both violations occur, and the database will report an error for at least one of them, preventing the insert. This is the correct behavior because both constraints are enforced at insert time in standard SQL, ensuring data integrity for unique and non-negative inventory values.

Why this answer

PRIMARY KEY constraints enforce uniqueness and implicitly disallow NULLs, while CHECK constraints validate that column values meet a Boolean condition on both INSERT and UPDATE. In this scenario, the NULL SKU violates the primary key, and the negative quantity violates the check constraint, so the insert is rejected. Both constraints work together to maintain data integrity.

Exam trap

The trap here is believing that PRIMARY KEY constraints permit NULL values or that CHECK constraints only apply to updates, when in fact both are enforced on insert.

5
MCQhard

A database architect is designing a schema for a high-volume transaction system. The system requires strict data consistency and supports complex queries with multiple joins. The architect must choose between a normalized relational model and a denormalized model. Which approach is most appropriate and why?

A.Use a denormalized model to reduce the number of joins and improve read performance, accepting some data redundancy.
B.Use a NoSQL document store to handle high volume and avoid joins altogether.
C.Use a star schema with fact and dimension tables to optimize complex queries, as it is a form of denormalization.
D.Use a normalized relational model to minimize redundancy and ensure data integrity, while adding indexes to optimize join performance.
AnswerD

A normalized model reduces data redundancy and maintains consistency, which is critical for transactional systems. Complex queries with joins can be optimized with proper indexing. This approach aligns with the need for strict consistency and supports complex queries without sacrificing integrity.

Why this answer

A normalized relational model is best suited for high-volume transaction systems that require strict consistency and complex queries. It minimizes redundancy and maintains integrity, while indexes can address join performance. Denormalization or NoSQL alternatives compromise consistency or join capabilities.

Exam trap

The trap here is assuming that denormalization always improves performance, overlooking the need for strict consistency and complex joins in transactional systems.

6
MCQmedium

A financial services company stores trade records in a table where the combination of TradeDate and TradeID must be unique, but individual TradeID values can repeat on different dates. The database administrator needs to enforce this uniqueness at the database level. Which constraint should be implemented?

A.FOREIGN KEY (TradeID) REFERENCES Trades(TradeID)
B.CHECK (TradeDate IS NOT NULL AND TradeID IS NOT NULL)
C.UNIQUE (TradeDate, TradeID)
D.PRIMARY KEY (TradeDate, TradeID)
AnswerC

A composite UNIQUE constraint enforces that no two rows can have the same combination of TradeDate and TradeID, while still allowing individual TradeID values to repeat across different dates. It also permits NULLs (depending on the DBMS) and can coexist with a primary key on another column, making it the precise fit for this requirement.

Why this answer

The requirement is to ensure that each TradeDate and TradeID combination is unique while allowing individual TradeID values to repeat on different dates. A composite UNIQUE constraint achieves exactly this by creating a unique index on both columns together. It does not restrict NULLs or conflict with a separate primary key, and it enforces the business rule at the database level without over-constraining the data.

Exam trap

The trap here is assuming that a composite PRIMARY KEY is the only way to enforce uniqueness across multiple columns, when a UNIQUE constraint can do the same without the additional restrictions of a primary key.

7
MCQmedium

A data engineer is designing a table that stores sensor readings. Each row must include the sensor ID, a timestamp, and a numeric reading. The sensor ID and timestamp together uniquely identify each row, and the table will be queried frequently by sensor ID for the most recent reading. Which table design best supports this scenario?

A.Create a clustered index on reading_time and a separate nonclustered index on sensor_id.
B.Create a primary key on sensor_id only and rely on application logic to prevent duplicate timestamps.
C.Create a composite primary key on (sensor_id, reading_time) and add a nonclustered index on (sensor_id, reading_time DESC).
D.Create a surrogate integer primary key and no additional indexes on sensor_id or reading_time.
AnswerC

A composite primary key on sensor_id and reading_time enforces uniqueness for each sensor reading. Adding a nonclustered index on sensor_id and reading_time descending allows the query optimizer to efficiently retrieve the most recent reading per sensor. This design balances data integrity with query performance for the stated access pattern.

Why this answer

The correct design uses a composite primary key to enforce the natural uniqueness of sensor_id and reading_time, and a composite nonclustered index to accelerate the common query for the latest reading per sensor. This approach maintains data integrity while optimizing for the specified access pattern.

Exam trap

The trap here is assuming a surrogate primary key is always sufficient and overlooking the need for a composite index that matches the query pattern.

8
MCQeasy

A data analyst needs to retrieve a list of all unique countries from a Customers table, sorted alphabetically. Which SQL statement should be used?

A.SELECT DISTINCT country FROM Customers ORDER BY country;
B.SELECT country FROM Customers GROUP BY country;
C.SELECT country FROM Customers ORDER BY country;
D.SELECT UNIQUE country FROM Customers ORDER BY country;
AnswerA

This statement uses the DISTINCT keyword to return only unique country values and then sorts them alphabetically with ORDER BY. It precisely meets the requirement of retrieving a list of unique countries sorted alphabetically. This is the correct and efficient solution.

Why this answer

To retrieve unique countries sorted alphabetically, the DISTINCT keyword must be used to eliminate duplicates, and ORDER BY country must be used to sort the results. This combination directly fulfills both requirements in a single, standard SQL statement.

Exam trap

The trap here is forgetting that without DISTINCT, duplicate country values will appear even if the query is sorted.

9
MCQhard

An application requires an automatic timestamp for every row inserted into an 'Audit' table. Which feature should the developer implement?

A.Index
B.Constraint
C.Trigger
D.View
AnswerC

A trigger executes automatically on each insert, setting the timestamp column without application intervention. This satisfies the requirement for an automatic timestamp on every row, unlike defaults that only apply when no value is supplied, or computed columns that cannot capture insertion time reliably.

Why this answer

A trigger is a special type of stored procedure that automatically executes in response to certain events on a table or view, such as INSERT, UPDATE, or DELETE. To automatically timestamp every row inserted into an 'Audit' table, the developer should implement an AFTER INSERT trigger that updates the timestamp column with the current date and time.

Exam trap

DS0-001 often tests the difference between triggers and constraints, and candidates may choose a constraint (like DEFAULT) when the question implies the need for more complex automatic actions.

How to eliminate wrong answers

Option A is wrong because an index is used to speed up data retrieval and does not perform automatic actions. Option B is wrong because a constraint enforces data integrity rules but cannot automatically set a timestamp. Option D is wrong because a view is a virtual table based on a SELECT statement and does not provide automatic timestamping on insert.

10
Multi-Selecteasy

Which TWO of the following are DDL (Data Definition Language) commands?

Select 2 answers
A.DROP
B.INSERT
C.CREATE
D.SELECT
E.UPDATE
AnswersA, C

DROP is a DDL command because it alters the database schema by removing an existing table, view or index definition entirely. Unlike DML statements such as DELETE, which remove rows while preserving the object, DROP satisfies the stem's requirement for commands that define or restructure schema objects.

Why this answer

DROP (A) is a DDL command because it removes entire database objects such as tables, views, or indexes from the schema, altering the database structure. CREATE (C) is also DDL since it defines new database objects like tables, indexes, or schemas, changing the structure of the database. INSERT (B) is a DML command used to add rows of data into existing tables, not to change schema.

SELECT (D) is a DML/DQL command that retrieves data and does not modify database structure. UPDATE (E) is DML because it modifies existing row values within a table rather than defining or altering schema objects.

Exam trap

DS0-001 often tests the distinction between DDL and DML, and candidates frequently confuse CREATE and DROP with data manipulation commands like INSERT or UPDATE, leading them to select incorrect options.

11
MCQmedium

A data analyst needs to calculate the average order value per customer for the previous month. The Orders table contains CustomerID, OrderID, and OrderTotal. The analyst writes a query that includes the AVG(OrderTotal) function and groups by CustomerID. However, the result shows some customers with an average of NULL. Which condition could cause this?

A.The OrderTotal column contains NULL values for some orders, and AVG ignores NULLs, resulting in a NULL average if all orders for a customer have NULL totals.
B.The GROUP BY clause is missing the OrderID column, causing incorrect grouping and NULL averages.
C.The AVG function cannot be used with a GROUP BY clause and returns NULL when grouped.
D.The query is filtering out orders with zero totals, and AVG treats zero as NULL.
AnswerA

AVG ignores NULL values in its calculation. If all orders for a particular customer have NULL OrderTotal, the AVG function has no non-NULL values to average, and it returns NULL for that customer. This is a common cause of NULL averages in aggregate queries. The analyst should handle NULLs explicitly if a different behavior is desired.

Why this answer

The AVG function ignores NULL values. If a customer has orders but all their OrderTotal values are NULL, the average calculation has no valid input and returns NULL. This is the most likely cause of the NULL averages.

To avoid this, the analyst could use COALESCE to substitute NULLs with zero or filter out such customers depending on the business requirement.

Exam trap

The trap here is assuming that AVG includes NULLs as zeros, when in fact it ignores them, which can lead to unexpected NULL results when all values in a group are NULL.

12
Multi-Selecteasy

Which TWO of the following statements about SQL are true?

Select 2 answers
A.SQL is for relational databases
B.SQL is only for Linux systems
C.DDL is used for modifying rows
D.DML includes INSERT and UPDATE
E.NoSQL cannot use SQL
AnswersA, D

SQL is the standard query language for relational databases, operating over tables with rows and columns and enforcing schema through primary and foreign keys. This directly satisfies the stem's requirement for a true statement about SQL's role, since relational systems such as SQL Server, PostgreSQL and MySQL all expose SQL as their primary interface.

Why this answer

Option A is correct because SQL (Structured Query Language) is the standard language designed for querying and managing relational databases, where data is stored in tables with rows and columns and relationships are defined via keys. Option D is correct because DML (Data Manipulation Language) is the SQL subset that works with the data itself, and its core statements include INSERT (to add rows), UPDATE (to modify existing rows), and DELETE (to remove rows). Option B is incorrect because SQL is platform-independent and runs on Windows, Linux, macOS, and mainframe systems alike.

Option C is incorrect because DDL (Data Definition Language) deals with schema objects such as CREATE, ALTER, and DROP for tables, indexes, and databases, not with modifying individual rows. Option E is incorrect because several NoSQL systems (for example, Cassandra with CQL and some document databases) do provide SQL-like query languages, so the blanket claim that NoSQL cannot use SQL is false.

Exam trap

DS0-001 often tests whether candidates conflate DDL with DML, so the trap is choosing 'DDL is used for modifying rows' when DDL actually defines or alters schema structures, not row data.

13
MCQhard

A query is slow due to excessive scanning of a large table. The execution plan shows a 'Table Scan'. What is the most likely missing element?

A.A view
B.An index
C.A stored procedure
D.A trigger
AnswerB

A table scan reads every row because no ordered access path exists for the predicate or join columns. Creating an index on the filtered or joined column lets the optimiser perform a seek or range scan, drastically reducing pages read.

Why this answer

A Table Scan in an execution plan means the database engine is reading every row of the table to satisfy the query, which is expensive on large tables. An index provides a sorted access path that lets the optimizer seek directly to matching rows instead of scanning the whole table, dramatically reducing I/O. Adding an appropriate index on the columns used in WHERE, JOIN, or ORDER BY clauses is the standard fix.

Exam trap

The trap here is confusing logical database objects (views, procedures, triggers) with physical access structures (indexes) — only an index changes how rows are physically located during query execution.

How to eliminate wrong answers

Option A is wrong because a view is just a stored query definition and does not change how the underlying data is accessed — it can even worsen performance if it obscures predicates. Option C is wrong because a stored procedure is a batch of SQL logic, not a data-access structure, and does not eliminate table scans. Option D is wrong because a trigger fires on DML events and has no role in optimizing read query plans.

14
MCQeasy

A developer needs to retrieve a list of all customers who have placed at least one order, along with the total amount spent by each. The 'Customers' table has one row per customer, and the 'Orders' table has one row per order with a 'CustomerID' foreign key. Which SQL construct should the developer use?

A.SELECT with a CROSS JOIN between Customers and Orders and a HAVING clause on total amount
B.SELECT with a RIGHT JOIN from Customers to Orders and a GROUP BY on order ID
C.SELECT with an INNER JOIN between Customers and Orders, grouped by customer, with SUM on order amount
D.SELECT with a LEFT JOIN from Customers to Orders and a WHERE clause excluding NULL order amounts
AnswerC

An INNER JOIN returns only customers who have matching order rows, which satisfies the requirement to list customers who placed at least one order. Grouping by customer and applying SUM to the order amount produces the total spent per customer, directly matching the requested output without extra filtering.

Why this answer

An INNER JOIN between Customers and Orders returns only customers with matching orders, and grouping by customer with SUM on the order amount yields the total spent per customer. The other joins either include unmatched rows, create a Cartesian product, or group at the wrong level.

Exam trap

The trap here is overcomplicating the query with outer joins when a plain INNER JOIN already satisfies the requirement of customers who placed orders.

15
Multi-Selectmedium

A retail company is designing a data warehouse star schema for sales analysis. The team must choose attributes for the fact table and the dimension tables. Which TWO of the following should be placed in the fact table rather than a dimension table? (Choose two.)

Select 2 answers
A.Store city where each sale occurred
B.Quantity of units sold in each transaction line
C.Customer loyalty tier at time of purchase
D.Product category name assigned to each item
E.Extended sales amount for each transaction line
AnswersB, E

Quantity is a numeric measure that varies per transaction and is aggregated across dimensions such as product, store, and time. Measures like this belong in the fact table because they are the values being summed, averaged, or compared during analysis, and they are meaningless without the dimension context that describes them.

Why this answer

Fact tables hold numeric, additive measures that analysts aggregate, such as quantity sold and extended sales amount. Dimension tables hold descriptive attributes that provide context for those measures, including product category, store city, and customer loyalty tier. Separating measures from descriptors keeps the star schema efficient and supports flexible slicing across dimensions.

Exam trap

The trap here is treating any column that appears in sales records as a fact, when descriptive attributes such as city or category belong in dimensions.

16
MCQeasy

A user wants to add a new column to an existing table named 'Employees'. Which SQL statement should be executed?

A.MODIFY TABLE
B.UPDATE TABLE
C.CREATE COLUMN
D.ALTER TABLE
AnswerD

ALTER TABLE modifies the structure of an existing table, so it adds the new column to Employees without dropping data. CREATE TABLE builds a new table and UPDATE changes row values, neither of which alters the schema.

Why this answer

The ALTER TABLE statement is the standard SQL DDL command used to modify the structure of an existing table, including adding, dropping, or modifying columns. To add a new column to 'Employees', the correct syntax is ALTER TABLE Employees ADD column_name data_type.

Exam trap

DS0-001 often tests the confusion between DDL and DML statements, causing candidates to select UPDATE (which modifies data) instead of ALTER TABLE (which modifies structure).

How to eliminate wrong answers

Option A is wrong because MODIFY TABLE is not a valid SQL statement; MODIFY is a clause used within ALTER TABLE in some dialects (e.g., MySQL) but not a standalone command. Option B is wrong because UPDATE TABLE is not valid SQL; UPDATE is a DML statement for modifying row data, not table structure. Option C is wrong because CREATE COLUMN is not a valid SQL statement; CREATE is used for creating tables, views, or other objects, not individual columns.

17
MCQmedium

An application is experiencing deadlocks. Which strategy would effectively reduce the frequency of deadlocks?

A.Uniform access order
B.Enabling indexing
C.Using read-only databases
D.Increasing table size
AnswerA

Imposing a uniform access order means every transaction acquires locks in the same sequence, eliminating the circular-wait condition that produces deadlocks. This directly addresses the scenario's deadlock frequency by removing one of the four Coffman conditions rather than merely retrying after failure.

Why this answer

Accessing tables in the same order across different transactions is a primary method to prevent circular wait conditions that cause deadlocks.

18
MCQmedium

Which SQL command is used to permanently remove all rows from a table while keeping the table definition intact?

A.DELETE
B.DROP
C.REMOVE
D.TRUNCATE
AnswerD

TRUNCATE removes all rows by deallocating the table's data pages, a minimally logged operation that resets the table to empty while preserving its schema, columns, and indexes. This satisfies the stem's requirement to delete every row permanently yet keep the table definition intact, unlike DROP, which eliminates the structure itself.

Why this answer

TRUNCATE is a DDL operation that removes all rows from a table in a single transaction-efficient operation while preserving the table's structure, columns, constraints, and indexes. It deallocates the data pages rather than logging each row deletion, making it far faster than DELETE for clearing a table. The table definition remains intact and ready for new inserts.

Exam trap

DS0-001 often tests the DELETE vs TRUNCATE vs DROP distinction, catching candidates who forget that TRUNCATE preserves the table definition while DROP destroys it, or who assume DELETE is the fastest way to clear a table.

How to eliminate wrong answers

Option A is wrong because DELETE is a DML operation that removes rows one at a time, can be filtered with a WHERE clause, is fully logged, and can be rolled back — it does not 'permanently remove all rows' in the efficient, definition-preserving sense the question describes, and without a WHERE clause it is slower and more resource-intensive than TRUNCATE. Option B is wrong because DROP removes the entire table including its definition, indexes, constraints, and privileges — the table ceases to exist, which contradicts 'keeping the table definition intact'. Option C is wrong because REMOVE is not a valid SQL command; it is a common distractor that does not exist in standard SQL.

19
Multi-Selecthard

Which THREE of the following are standard SQL aggregate functions?

Select 3 answers
A.AVG
B.SUM
C.SELECT
D.COUNT
E.DELETE
AnswersA, B, D

AVG is a standard SQL aggregate function that returns the arithmetic mean of a numeric column across rows, satisfying the stem's requirement. It collapses multiple rows into one value, distinguishing aggregates from scalar functions that operate per row.

Why this answer

AVG (option A) is a standard SQL aggregate function that returns the average value of a numeric column, making it correct. SUM (option B) is also a standard aggregate function that totals the values in a numeric column, so it is correct. COUNT (option D) is a standard aggregate function that returns the number of rows or non-NULL values, so it is correct.

SELECT (option C) is a data retrieval statement, not an aggregate function, and DELETE (option E) is a data manipulation statement used to remove rows, so neither belongs among aggregate functions.

Exam trap

DS0-001 often tests the confusion between SQL statements and aggregate functions — candidates pick SELECT or DELETE because they are familiar SQL keywords, missing that aggregates must summarize multiple rows into one value.

20
Multi-Selecthard

A database administrator is reviewing a schema and needs to ensure data integrity. Which TWO of the following are valid SQL constraints that can be applied to a column to enforce data integrity? (Choose two.)

Select 2 answers
A.VIEW
B.TRIGGER
C.FOREIGN KEY
D.PRIMARY KEY
E.INDEX
AnswersC, D

A FOREIGN KEY constraint establishes a link between data in two tables, ensuring that the value in one table matches a value in another. It enforces referential integrity, preventing orphaned records and maintaining consistent relationships. This is a key mechanism for data integrity across related tables.

Why this answer

PRIMARY KEY and FOREIGN KEY are both SQL constraints that enforce data integrity. PRIMARY KEY ensures unique and non-null identification of rows, while FOREIGN KEY enforces referential integrity between tables. These constraints are defined at the column or table level and are essential for maintaining consistent and reliable data.

Exam trap

The trap here is confusing database objects like INDEX, TRIGGER, and VIEW with actual constraints that enforce integrity.

21
MCQeasy

Which DML statement is used to update existing records in a database table?

A.ALTER
B.UPDATE
C.MODIFY
D.INSERT
AnswerB

UPDATE modifies existing rows in a table, setting new column values for records matched by the WHERE clause. This satisfies the stem's constraint of changing existing records, unlike INSERT, which adds new rows, or DELETE, which removes them.

Why this answer

The UPDATE statement modifies the data of existing rows in a table.

22
MCQeasy

Which operator is used to search for a pattern in a string column?

A.IN
B.CONTAINS
C.LIKE
D.MATCH
AnswerC

LIKE performs pattern matching on string columns using wildcards such as % and _, satisfying the requirement to search for a pattern rather than an exact value. Equality operators match whole values only, so LIKE is the operator that filters rows by substring or pattern.

Why this answer

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

23
MCQmedium

To improve read performance on a table frequently queried by a specific column, which database object should be created?

A.Index
B.View
C.Stored Procedure
D.Trigger
AnswerA

An index maintains a sorted structure on the queried column, letting the database locate matching rows without scanning the entire table. This directly satisfies the stem's read-performance constraint, trading additional storage and slower writes for faster lookups on that column.

Why this answer

An index on the frequently queried column allows the database engine to locate rows without scanning the entire table, dramatically improving read performance for SELECT queries filtering or joining on that column. Indexes create a sorted structure (B-tree) that enables fast seeks and range scans.

Exam trap

The trap is confusing objects that encapsulate logic (views, stored procedures, triggers) with the object that actually accelerates data retrieval — only an index changes the physical access path.

How to eliminate wrong answers

Option B is wrong because a view is a saved query that does not store data or provide faster access by itself; it only simplifies query writing unless indexed (indexed views are a special case). Option C is wrong because a stored procedure encapsulates logic but does not inherently speed up reads on a column. Option D is wrong because a trigger fires automatically on DML events and adds overhead rather than improving read performance.

24
MCQmedium

A database developer needs to combine the results of two different SELECT queries into a single result set. Which operator should be used?

A.JOIN
B.CONCAT
C.UNION
D.MERGE
AnswerC

UNION concatenates the row sets from two SELECT statements into one result set, eliminating duplicate rows by default. It satisfies the stem's requirement to combine results from two different queries, provided both have matching column counts and compatible data types in corresponding positions.

Why this answer

UNION combines the row sets of two SELECT statements into one result set, stacking rows vertically and removing duplicates (UNION ALL keeps them). It requires the same number of columns and compatible data types in matching positions. JOIN, by contrast, combines columns horizontally based on a join condition.

Exam trap

The trap is conflating horizontal combination (JOIN) with vertical combination (UNION); candidates who see 'combine two queries' often reflexively pick JOIN.

How to eliminate wrong answers

Option A is wrong because JOIN merges columns from two tables side by side based on a matching key, not stacking the rows of two independent queries. Option B is wrong because CONCAT is a string function that appends character values, not a set operator for combining result sets. Option D is wrong because MERGE is a DML statement (upsert) that inserts, updates, or deletes rows in a target table based on a source, not a query-combining operator.

25
MCQhard

A financial analyst runs a query that joins a 500-million-row transactions table to a 200-row currency table on a non-indexed currency code column. The optimizer chooses a nested loop join and the query runs for hours. Which execution strategy should the analyst encourage to improve performance most effectively?

A.Cross join followed by a WHERE filter on matching currency codes
B.Merge join, requiring both inputs to be sorted on currency code
C.Hash join, building a hash table on the small currency table
D.Nested loop join with a larger sort area allocated to the session
AnswerC

A hash join reads the smaller currency table once, builds an in-memory hash table on the currency code, then probes it for each transaction row. This converts the nested loop's repeated scans of the large table into a single pass, which is far more efficient when the join column is not indexed and the large table dominates the cost.

Why this answer

When one input is very small and the join column on the large input is unindexed, a hash join avoids repeated scans by building an in-memory hash table from the small table and probing it once per large-table row. Merge joins need sorted inputs, nested loops repeat inner scans, and cross joins explode the result set, so the hash join is the most effective strategy here.

Exam trap

The trap here is assuming that increasing memory or sort area will fix a nested loop join when the real issue is the join algorithm's repeated scanning of the large table.

26
MCQeasy

Which SQL keyword is used to eliminate duplicate values from a query result set?

A.UNIQUE
B.GROUP BY
C.FILTER
D.DISTINCT
AnswerD

DISTINCT filters the result set so each unique combination of selected column values appears only once, directly satisfying the requirement to eliminate duplicate rows. It operates on the full SELECT list rather than a single column, unlike GROUP BY, which aggregates rows and is intended for summary calculations.

Why this answer

The DISTINCT keyword is used in a SELECT statement to return only unique values.

27
MCQhard

A database administrator is reviewing a query that joins a large Sales table with a small Regions table. The query filters on a column in the Regions table and returns only matching rows from both tables. The administrator notices that the query plan shows a nested loop join. Which factor most likely influenced the optimizer's choice of this join method?

A.The query lacks a WHERE clause, causing the optimizer to default to a nested loop join for all rows.
B.The join condition uses an inequality, which is only supported by nested loop joins.
C.The Regions table is small and has an index on the join column, making it efficient to probe for each row of the Sales table.
D.The Sales table is large and has no indexes, forcing a full table scan for each iteration of the outer loop.
AnswerC

A nested loop join is often chosen when one input is small and can be efficiently probed, especially if an index exists on the join column of the inner table. Here, the Regions table is small, and if it has an index on the join column, the optimizer can quickly find matching rows for each row of the larger Sales table. This is a classic scenario for nested loop joins.

Why this answer

The optimizer likely chose a nested loop join because the Regions table is small and, with an index on the join column, can be efficiently probed for each row of the larger Sales table. This access pattern minimizes I/O and is well-suited for joining a large table with a small, indexed table. Other join methods would be less efficient in this context.

Exam trap

The trap here is assuming that a nested loop join is always inefficient for large tables, when in fact it can be optimal when the inner table is small and indexed.

28
MCQhard

A database administrator is designing a schema for a new order processing system. The system must enforce that every order is associated with exactly one customer, and that a customer can place many orders. Which relationship type and implementation should be used?

A.One-to-many relationship, implemented by placing a foreign key in the Orders table that references the primary key of the Customers table.
B.Many-to-many relationship, implemented by creating a junction table containing foreign keys to both Customers and Orders.
C.One-to-many relationship, implemented by placing a foreign key in the Customers table that references the primary key of the Orders table.
D.One-to-one relationship, implemented by placing a foreign key in the Orders table that references the Customers table and adding a unique constraint on the foreign key column.
AnswerA

This design places a foreign key in the Orders table pointing to the Customers table. Each order references exactly one customer, and a customer can be referenced by many orders. This precisely implements the one-to-many relationship required by the scenario, with no unnecessary constraints.

Why this answer

The correct implementation is a one-to-many relationship with a foreign key in the Orders table referencing the Customers table. This allows each order to be linked to exactly one customer while enabling a customer to have multiple orders. It enforces the business rule without over-constraining the data.

Exam trap

The trap here is confusing the direction of the foreign key, placing it on the wrong side of the relationship.

29
Multi-Selectmedium

Which TWO of the following are common types of NoSQL databases?

Select 2 answers
A.Relational
B.Key-Value
C.Document
D.Hierarchical
E.Network
AnswersB, C

Key-value stores are a core NoSQL category, pairing each key with an opaque value and offering simple lookups without a fixed relational schema. This satisfies the question's demand for a common NoSQL database type, alongside document, column-family and graph stores.

Why this answer

Document and Key-Value stores are two primary categories of NoSQL databases.

30
Multi-Selectmedium

A database administrator is reviewing a schema for a reporting database. The team needs to ensure that queries against a large 'Sales' table return consistent results even if a long-running report is executing while new sales are being inserted. Which TWO of the following techniques help provide a consistent snapshot of data for the report? (Choose two.)

Select 2 answers
A.Add a NOLOCK hint to every table in the report query
B.Query a read-only replica that is synchronized through log shipping
C.Set the transaction isolation level to READ UNCOMMITTED for the report
D.Increase the database transaction log size to reduce checkpoint frequency
E.Use a transaction with an isolation level that provides snapshot or repeatable read semantics
AnswersB, E

A read-only replica receiving log-shipped changes provides a separate copy of the data that can be queried without interfering with the primary. If the replica is consistent at a point in time, the report sees a stable dataset even while the primary continues to accept inserts, which supports consistent reporting without blocking writers.

Why this answer

Snapshot or repeatable-read isolation and querying a synchronized read-only replica both give the report a stable view of the data while writers continue. Dirty-read techniques such as READ UNCOMMITTED or NOLOCK sacrifice consistency, and log sizing affects recovery rather than read consistency.

Exam trap

The trap here is equating reduced blocking with consistency, leading to selection of dirty-read options that actually undermine report accuracy.

31
Multi-Selecthard

A database team is designing a new table to store employee data. They need to ensure that the table structure supports efficient queries and maintains data integrity. Which two of the following statements about primary keys and indexes are true? (Choose two.)

Select 2 answers
A.A unique index can be created on a column that allows NULL values, and multiple NULLs are permitted in some DBMSs.
B.Indexes always improve the performance of INSERT, UPDATE, and DELETE operations.
C.A foreign key constraint automatically creates an index on the foreign key column(s) in all DBMSs.
D.A table can have multiple primary keys to improve query performance.
E.A primary key constraint automatically creates a unique index on the key column(s).
AnswersA, E

A unique index enforces uniqueness but does not necessarily prohibit NULLs. In many database systems, such as SQL Server and PostgreSQL, multiple NULLs are allowed in a unique index because NULL is considered distinct from other NULLs. This allows flexibility while still preventing duplicate non-NULL values. However, behavior varies, so it's important to check the specific DBMS documentation.

Why this answer

The true statements are that a primary key automatically creates a unique index, and that a unique index can allow multiple NULLs in some DBMSs. These reflect standard behaviors that affect both data integrity and query performance. The other statements are false because a table can have only one primary key, indexes can slow down data modifications, and foreign key indexing is not automatic in all systems.

Exam trap

The trap here is assuming that all DBMSs behave the same regarding automatic indexing of foreign keys and handling of NULLs in unique indexes, when in fact these behaviors vary by vendor.

32
MCQmedium

A database developer is writing a query that must return the product_name and the total quantity sold for each product from a Sales table. The Sales table contains product_id, quantity, and sale_date. The Products table contains product_id and product_name. The query should include only products that have total sales quantity greater than 100. Which SQL statement is correct?

A.SELECT p.product_name, SUM(s.quantity) AS total_qty FROM Sales s JOIN Products p ON s.product_id = p.product_id GROUP BY p.product_name HAVING SUM(s.quantity) > 100;
B.SELECT p.product_name, SUM(s.quantity) AS total_qty FROM Sales s JOIN Products p ON s.product_id = p.product_id WHERE SUM(s.quantity) > 100 GROUP BY p.product_name;
C.SELECT p.product_name, SUM(s.quantity) AS total_qty FROM Sales s JOIN Products p ON s.product_id = p.product_id GROUP BY p.product_name, s.quantity HAVING s.quantity > 100;
D.SELECT p.product_name, SUM(s.quantity) AS total_qty FROM Sales s, Products p WHERE s.product_id = p.product_id GROUP BY p.product_name HAVING total_qty > 100;
AnswerA

This query joins Sales and Products, groups by product_name, and sums the quantity. The HAVING clause filters groups where the sum exceeds 100. It correctly returns only products meeting the sales threshold, with the required columns. This is the proper use of GROUP BY and HAVING.

Why this answer

The correct query joins the two tables, groups by product_name, and uses HAVING to filter on the aggregate sum. This ensures that only products with total quantity sold greater than 100 are returned. The HAVING clause is essential for filtering grouped results based on aggregate conditions.

Exam trap

The trap here is using WHERE instead of HAVING to filter on an aggregate function, which is invalid SQL.

33
MCQhard

A developer needs to calculate the running total of sales. Which SQL feature is most appropriate?

A.GROUP BY
B.Trigger
C.Window Function
D.Recursive CTE
AnswerC

Window functions compute aggregates across a set of rows while retaining each individual row, so `SUM(sales) OVER (ORDER BY date)` returns a running total without collapsing detail. This directly satisfies the developer's requirement for cumulative sales, unlike GROUP BY, which reduces rows and cannot produce per-row running values.

Why this answer

A window function computes an aggregate or ranking value across a set of rows related to the current row without collapsing them, which is exactly what a running total requires. Using SUM(sales) OVER (ORDER BY date) produces a cumulative sum that grows row by row while preserving every detail row. This is the canonical use case for window functions such as SUM, AVG, RANK, and ROW_NUMBER with an OVER clause.

Exam trap

DS0-001 often tests the GROUP BY vs window function distinction, catching candidates who pick GROUP BY for cumulative calculations and forget that GROUP BY collapses rows while window functions preserve them.

How to eliminate wrong answers

Option A is wrong because GROUP BY collapses rows into aggregated groups, so you lose the individual sales rows and cannot produce a row-by-row running total — it gives one total per group, not a cumulative sequence. Option B is wrong because a trigger is a procedural event handler that fires on INSERT/UPDATE/DELETE, not a query feature for calculating running totals. Option D is wrong because a recursive CTE is used for hierarchical or graph traversal (e.g., org charts, bill of materials), not for cumulative aggregation over an ordered set — it is overkill and the wrong tool for a running total.

34
MCQhard

To implement a secure 'Multi-Tenant' architecture, which design approach is most effective for data separation?

A.Shared columns
B.Separate schemas
C.Indexing
D.Stored procedures
AnswerB

Separate schemas give each tenant its own tables and namespace within a shared database instance, so queries and permissions are scoped per tenant. This provides stronger logical isolation than shared tables with tenant-ID columns, satisfying the requirement for effective data separation in a multi-tenant architecture.

Why this answer

Separate schemas provide strong logical isolation by giving each tenant its own namespace of objects, enabling independent permission management and reducing cross-tenant data exposure. This approach balances security and manageability better than sharing columns, which risks accidental data leakage between tenants.

Exam trap

DS0-001 often tests whether candidates confuse performance features (indexing, stored procedures) with isolation mechanisms, so choose the option that actually separates tenant data at a structural level.

How to eliminate wrong answers

Option A is wrong because shared columns (e.g., a TenantID column in a shared table) require every query to filter correctly; a single missing WHERE clause can expose another tenant's data, and it complicates per-tenant customization. Option C is wrong because indexing is a performance optimization, not a data-separation mechanism — it does nothing to isolate tenants. Option D is wrong because stored procedures encapsulate logic but do not by themselves segregate tenant data; they still operate on whatever tables exist.

35
MCQeasy

Which type of join should be used to return all records from the 'Left' table and only matching records from the 'Right' table?

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

A LEFT JOIN returns every row from the left table plus matched rows from the right, filling unmatched right columns with NULL. That precisely satisfies the requirement to preserve all Left records while including only matching Right records.

Why this answer

A LEFT JOIN (LEFT OUTER JOIN) returns every row from the left table regardless of whether a match exists in the right table, and for unmatched rows it fills right-table columns with NULLs. This is exactly the behavior described: all left records plus only matching right records.

Exam trap

The trap is mixing up which side is preserved — candidates often pick RIGHT JOIN thinking 'right' means 'correct' or confuse the preserved side, especially when the question phrases it as 'all records from the Left table.'

How to eliminate wrong answers

Option A is wrong because INNER JOIN returns only rows where the join key matches in both tables, discarding unmatched left rows. Option B is wrong because RIGHT JOIN returns all rows from the right table and only matching rows from the left — the mirror image of what the question asks. Option C is wrong because FULL JOIN (FULL OUTER JOIN) returns all rows from both tables, filling NULLs on whichever side lacks a match, which includes non-matching right rows the question wants excluded.

36
Multi-Selecthard

Which TWO of the following scenarios are best suited for using a 'View'?

Select 2 answers
A.Simplifying complex joins
B.Storing large binary objects
C.Improving write speed
D.Implementing security access
E.Generating unique sequences
AnswersA, D

A view stores a predefined SELECT statement, so the join logic is written once and reused. This directly satisfies the scenario's need to simplify complex joins, hiding multi-table syntax behind a single named object that users query as if it were one table.

Why this answer

Views are best for simplifying complex queries and implementing row/column level security.

37
MCQmedium

To prevent unauthorized access to specific columns in a 'Salary' table, which object should be created for the reporting team?

A.View
B.Index
C.Sequence
D.Stored Procedure
AnswerA

A view exposes only selected columns and rows from the Salary table, letting the reporting team query permitted data while salary columns remain hidden. Granting access to the view rather than the base table enforces column-level restriction, satisfying the requirement to prevent unauthorised access to specific columns.

Why this answer

A view is a virtual table defined by a SELECT statement that exposes only the columns and rows the creator chooses to include. By creating a view that selects only non-sensitive columns from the 'Salary' table and granting the reporting team SELECT permission on the view (rather than on the base table), column-level access is restricted without duplicating data. This is the standard SQL mechanism for column-level security when row-level or table-level grants are too coarse.

Exam trap

DS0-001 often tests the distinction between objects that control access (views, stored procedures) and objects that control performance or data generation (indexes, sequences), so candidates who focus on 'reporting performance' may wrongly pick an index.

How to eliminate wrong answers

Option B is wrong because an index is a performance structure that speeds up data retrieval; it does not restrict which columns a user can see and actually requires access to the underlying table. Option C is wrong because a sequence is an object that generates numeric values (often for surrogate keys) and has nothing to do with access control. Option D is wrong because a stored procedure encapsulates logic and can restrict access indirectly, but it is not the object designed to expose a restricted column subset for ad-hoc reporting queries; a view is the direct, purpose-built solution.

38
MCQmedium

An analyst is writing an SQL query to retrieve total sales per region, but the result must only show regions with more than 100 transactions. Which clause is required?

A.HAVING
B.ORDER BY
C.LIMIT
D.WHERE
AnswerA

HAVING filters grouped rows after aggregation, so it can restrict results to regions whose COUNT of transactions exceeds 100. WHERE cannot reference aggregate functions, making HAVING the only clause that satisfies this post-aggregation filter requirement.

Why this answer

The HAVING clause is used to filter the results of aggregate functions like SUM or COUNT. Since the requirement is to show only regions with more than 100 transactions, which is an aggregate condition, HAVING is required. WHERE cannot be used with aggregate functions.

Exam trap

DS0-001 often tests the difference between WHERE and HAVING, and candidates may incorrectly choose WHERE for filtering aggregate results.

How to eliminate wrong answers

Option B is wrong because ORDER BY sorts the result set but does not filter based on aggregate conditions. Option C is wrong because LIMIT restricts the number of rows returned, not filter by aggregate values. Option D is wrong because WHERE filters rows before grouping and cannot be used with aggregate functions like COUNT.

39
MCQhard

Which NoSQL structure is best suited for scenarios where data relationships are complex and frequently traversed?

A.Graph
B.Key-Value
C.Column-family
D.Document
AnswerA

Graph databases store nodes and edges as first-class entities, so relationships are persisted directly rather than inferred through joins. Traversal follows pointers between adjacent nodes, making multi-hop queries across complex, frequently changing relationships far faster than relational or document alternatives.

Why this answer

Graph databases store data as nodes and edges, where edges explicitly represent relationships between entities. This native adjacency structure allows traversals across connected data to be performed in near-constant time per hop, making them ideal when relationships are complex and frequently queried. Key-value, column-family, and document stores lack first-class relationship modeling, so multi-hop traversals require expensive joins or application-side processing.

Exam trap

DS0-001 often tests whether candidates confuse document stores' embedded references with true graph traversal, so the trap is picking Document because it can 'link' data, when only Graph provides native relationship traversal.

How to eliminate wrong answers

Option B is wrong because key-value stores only map a key to an opaque value with no native relationship construct, so traversing relationships requires application logic or secondary indexes. Option C is wrong because column-family stores optimize wide-row aggregation and sparse column access, not multi-hop relationship traversal. Option D is wrong because document stores embed related data inside documents or reference them by ID, but they do not provide efficient graph traversal across documents.

40
Multi-Selecthard

Which TWO of the following are common database maintenance tasks?

Select 2 answers
A.Rebooting the server weekly
B.Renaming every table
C.Updating statistics
D.Deleting all users
E.Rebuilding indexes
AnswersC, E

Statistics feed the query optimiser's cost estimates, so stale or missing statistics cause poor execution plans and slow queries. Regularly refreshing them is a routine maintenance activity, satisfying the stem's requirement for a common database maintenance task.

Why this answer

Updating statistics and rebuilding indexes are critical maintenance tasks to ensure optimal query performance.

41
MCQeasy

A database administrator needs to add a new column named 'loyalty_points' of type INTEGER to an existing 'customers' table without affecting existing rows' data. Which SQL statement should the administrator execute?

A.ALTER TABLE customers ADD COLUMN loyalty_points INTEGER;
B.INSERT INTO customers (loyalty_points) VALUES (INTEGER);
C.UPDATE TABLE customers ADD loyalty_points INTEGER;
D.CREATE TABLE customers ADD loyalty_points INTEGER;
AnswerA

The ALTER TABLE ... ADD COLUMN statement modifies the table's structure by appending a new column definition. Existing rows receive a NULL value for the new column unless a default is specified, so their data remains intact. This is the standard DDL statement for adding a column to an existing table in SQL.

Why this answer

Adding a column to an existing table is a schema change performed with ALTER TABLE ... ADD COLUMN. This preserves existing rows and populates the new column with NULL or a specified default.

UPDATE changes row values, INSERT adds rows, and CREATE TABLE builds new tables, so only the ALTER TABLE statement satisfies the requirement without disturbing existing data.

Exam trap

The trap here is confusing DML statements like UPDATE and INSERT, which manipulate row data, with DDL statements like ALTER TABLE, which change table structure.

42
MCQmedium

A database administrator needs to store unstructured data that scales horizontally across multiple servers while maintaining high availability. Which database structure should be selected?

A.Relational (RDBMS)
B.NoSQL (Document Store)
C.Network
D.Hierarchical
AnswerB

NoSQL document stores shard data across nodes using partition keys, satisfying the horizontal scaling and high availability constraints for unstructured content. Unlike relational engines, they avoid rigid schemas and single-node write bottlenecks, letting each server hold independent document subsets with replication for failover.

Why this answer

A NoSQL document store is designed for unstructured or semi-structured data and natively supports horizontal scaling through sharding and replication across commodity servers, delivering high availability via automatic failover. Document stores such as MongoDB or Couchbase store data as flexible JSON-like documents, so schema changes do not require migrations. This combination of schema flexibility, horizontal scale, and built-in replication matches the requirement precisely.

Exam trap

DS0-001 often tests the assumption that 'database' always means relational, catching candidates who overlook that unstructured data plus horizontal scaling plus high availability is the textbook definition of a NoSQL document store.

How to eliminate wrong answers

Option A is wrong because relational databases enforce a fixed schema and typically scale vertically (bigger server) rather than horizontally, making them a poor fit for unstructured data at scale — sharding an RDBMS is possible but complex and not its native strength. Option C is wrong because the network model is a legacy pre-relational structure using pointer-based sets, offers no horizontal scaling or high-availability features, and is effectively obsolete. Option D is wrong because the hierarchical model (e.g., IMS) organises data as a tree with parent-child links, cannot represent many-to-many relationships naturally, and has no native horizontal scaling or HA capability.

43
MCQmedium

Which scenario best justifies the use of a relational database over a NoSQL database?

A.Financial transactions
B.Big data analytics
C.Rapid prototyping
D.Social media feeds
AnswerA

Financial transactions demand ACID guarantees: atomicity, consistency, isolation and durability, enforced through strict schemas and multi-row transactions. A relational engine provides these natively, whereas most NoSQL stores trade full ACID compliance for horizontal scale and flexible schemas.

Why this answer

Financial transactions require strict ACID guarantees — atomicity, consistency, isolation, and durability — which relational databases provide natively through transactions and constraints. NoSQL databases typically relax these guarantees in favor of scalability and availability, making them unsuitable for scenarios where data integrity is paramount.

Exam trap

DS0-001 often tests the ACID-vs-BASE trade-off, and candidates may incorrectly associate relational databases with scalability limits or assume NoSQL is always the modern choice, missing that financial transactions demand strict consistency.

How to eliminate wrong answers

Option B is wrong because big data analytics often involves large volumes of semi-structured or unstructured data where NoSQL or columnar stores excel, and strict relational schemas can be a bottleneck. Option C is wrong because rapid prototyping benefits from the schema flexibility of NoSQL databases, which allow developers to iterate without migrations. Option D is wrong because social media feeds involve high-velocity, denormalized, and often eventually consistent data, which is a classic NoSQL use case.

44
MCQmedium

A database administrator wants to check the current connection count. Which system catalog or dynamic management view would typically provide this information?

A.Information Schema
B.System Tables
C.Dynamic Management Views
D.Audit Logs
AnswerC

Dynamic Management Views, such as sys.dm_exec_sessions and sys.dm_exec_connections, expose live session and connection state on SQL Server. Querying them returns the current connection count directly, unlike static catalogs that describe schema objects rather than runtime activity.

Why this answer

Dynamic Management Views (DMVs) in SQL Server, such as sys.dm_exec_connections and sys.dm_exec_sessions, expose real-time server state including current connection counts, session details, and resource usage. They are the standard mechanism for monitoring live connection activity because they query the running instance's internal state rather than static metadata. This makes DMVs the correct choice for checking current connection count.

Exam trap

DS0-001 often tests the confusion between metadata catalogs (INFORMATION_SCHEMA, system tables) and runtime monitoring views (DMVs) — candidates who don't distinguish static schema metadata from live server state pick the wrong catalog.

How to eliminate wrong answers

Option A is wrong because INFORMATION_SCHEMA views expose metadata about schema objects (tables, columns, constraints) as defined by the SQL standard — they do not report live connection or session counts. Option B is wrong because system tables (e.g., sys.objects, sys.tables) store catalog metadata about database objects, not runtime connection statistics. Option D is wrong because audit logs record historical events (logins, DDL changes) for compliance and forensics — they are not a live counter of current connections.

45
Multi-Selectmedium

Which THREE of the following are standard SQL join types?

Select 3 answers
A.TOP
B.LEFT
C.SORT
D.INNER
E.FULL
AnswersB, D, E

LEFT preserves all rows from the left table, returning NULLs for unmatched right-side columns. It satisfies the stem's requirement for a standard SQL join type, sitting alongside INNER, RIGHT, FULL OUTER and CROSS in the ANSI specification. Unlike set operators such as UNION, joins combine columns horizontally across related tables.

Why this answer

Option B (LEFT) is correct because LEFT JOIN (or LEFT OUTER JOIN) is a standard SQL join type that returns all rows from the left table plus matching rows from the right table, with NULLs where no match exists. Option D (INNER) is correct because INNER JOIN is the standard join that returns only rows with matching values in both tables based on the join predicate. Option E (FULL) is correct because FULL JOIN (or FULL OUTER JOIN) is a standard SQL join type that returns all rows from both tables, filling unmatched columns with NULLs.

Option A (TOP) is not a join type; it is a row-limiting clause used in T-SQL (e.g., SELECT TOP 10). Option C (SORT) is not a join type either; it is an operation or keyword associated with ordering results, not combining tables.

Exam trap

DS0-001 often tests SQL join types, and the trap is confusing join types with other SQL clauses like TOP or SORT, which are not joins at all.

46
Multi-Selecthard

Which TWO of the following are potential issues when denormalizing a database?

Select 2 answers
A.Data anomalies
B.Simplified data entry
C.Improved schema flexibility
D.Slower join performance
E.Increased storage usage
AnswersA, E

Denormalisation duplicates data across tables, so a single logical fact is stored in multiple places. When one copy is updated but others are not, insert, update and delete anomalies arise, producing inconsistent query results. This directly satisfies the stem's requirement to identify a genuine drawback of denormalising, unlike performance gains.

Why this answer

Denormalization intentionally duplicates data across tables to reduce joins, and this redundancy creates data anomalies (Option A): if a duplicated value is updated in one place but not another, the database can end up with inconsistent or conflicting records, violating update/insert/delete consistency. Denormalization also increases storage usage (Option E) because the same data is stored in multiple tables or columns, and additional indexes or summary columns may be added, consuming more disk space than a normalized design. The unmarked options do not belong because simplified data entry (B) and improved schema flexibility (C) are generally benefits rather than issues, and slower join performance (D) is incorrect since denormalization typically reduces the number of joins and can improve read performance.

Exam trap

DS0-001 often tests whether candidates can separate denormalization's benefits (fewer joins, faster reads) from its costs (anomalies, storage), so the trap is selecting 'slower join performance' because denormalization is associated with performance trade-offs.

47
MCQeasy

A database administrator needs to grant a new analyst read-only access to a specific table named 'SalesData' in a PostgreSQL database. The analyst should be able to query the table but not modify it. Which SQL statement should the administrator execute?

A.GRANT USAGE ON SalesData TO analyst;
B.GRANT ALL PRIVILEGES ON SalesData TO analyst;
C.GRANT READ ON SalesData TO analyst;
D.GRANT SELECT ON SalesData TO analyst;
AnswerD

GRANT SELECT ON SalesData TO analyst; provides the analyst with the privilege to run SELECT queries against the SalesData table. It does not grant INSERT, UPDATE, or DELETE privileges, so the analyst cannot modify data. This is the standard SQL statement for granting read-only access to a specific table in PostgreSQL and most other relational databases, directly fulfilling the requirement.

Why this answer

The GRANT SELECT statement is the correct way to provide read-only access to a table in PostgreSQL. It allows the analyst to query the table without granting modification rights. Other options either grant excessive privileges (ALL PRIVILEGES), use invalid privilege types (USAGE, READ), or fail to meet the requirement.

This aligns with the principle of least privilege.

Exam trap

The trap here is assuming that GRANT USAGE or GRANT READ works on tables, when in fact PostgreSQL uses SELECT for table read access.

48
MCQeasy

A database administrator needs to grant a user the ability to retrieve data from a specific table but must prevent the user from modifying or deleting any data. Which SQL statement should the administrator execute?

A.GRANT SELECT ON table_name TO user_name;
B.GRANT REFERENCES ON table_name TO user_name;
C.GRANT ALL PRIVILEGES ON table_name TO user_name;
D.GRANT INSERT, UPDATE, DELETE ON table_name TO user_name;
AnswerA

GRANT SELECT provides read-only access to the specified table. It allows the user to query data without granting INSERT, UPDATE, or DELETE privileges. This precisely meets the requirement of retrieving data while preventing modifications, following the principle of least privilege.

Why this answer

The correct statement is GRANT SELECT, which provides read-only access. It satisfies the need to retrieve data while ensuring the user cannot modify or delete records. Other options either grant excessive privileges or do not grant the necessary read access.

Exam trap

The trap here is confusing the REFERENCES privilege with read access, or assuming that ALL PRIVILEGES is necessary for a simple SELECT.

49
MCQhard

A data architect is designing a schema for a system that must store highly variable product attributes across thousands of categories, where each category has a different set of attributes and the schema must evolve frequently without downtime. Which database structure is best suited for this requirement?

A.A relational table with a fixed set of columns for all possible attributes
B.A normalized relational schema with an entity-attribute-value table
C.A document-oriented NoSQL store with a flexible schema per product
D.A star schema with a dimension table per attribute
AnswerC

A document-oriented store allows each product document to contain its own set of attributes, so categories with different attributes are represented naturally without schema migrations. This flexibility supports frequent evolution and avoids downtime, matching the requirement for highly variable product attributes across thousands of categories.

Why this answer

A document-oriented NoSQL store handles variable attributes per product without schema migrations, directly supporting frequent evolution and avoiding downtime. Fixed-column tables, attribute-per-dimension star schemas, and entity-attribute-value designs either require schema changes or introduce query complexity and performance issues.

Exam trap

The trap here is assuming that any schema-flexible relational pattern, such as entity-attribute-value, is equivalent to a document store, when its query and performance characteristics differ significantly.

50
MCQhard

When migrating data between two different relational databases, which DDL-related issue is most likely to cause failure if ignored?

A.Table naming conventions
B.Incompatible data types
C.Storage engine choice
D.Primary key naming
AnswerB

Source and target engines define types differently, so columns such as dates, booleans or decimals may lack an exact equivalent. Unmapped or narrowed types cause DDL creation to fail or silently truncate, breaking the migration before data loads.

Why this answer

Incompatible data types are the most likely DDL-related failure point when migrating between different relational database engines (e.g., Oracle to PostgreSQL, SQL Server to MySQL). Each RDBMS implements its own type system with different sizes, precision, and semantics — for example, Oracle's NUMBER vs. SQL Server's DECIMAL, or MySQL's TINYINT(1) vs.

PostgreSQL's BOOLEAN — so DDL that creates tables will fail or silently truncate data if types aren't mapped correctly.

Exam trap

DS0-001 often tests whether candidates confuse cosmetic DDL elements (names, storage engines) with functional ones (data types) — the trap is picking a naming-related answer because it sounds like a 'compatibility' issue.

How to eliminate wrong answers

Option A is wrong because table naming conventions are cosmetic — most DBMSs allow quoted identifiers and case-sensitivity differences rarely block a migration (they may require quoting but won't cause DDL failure). Option C is wrong because storage engine choice is an internal implementation detail (e.g., InnoDB vs. MyISAM in MySQL) and is not part of portable DDL — other RDBMSs don't expose the concept at all.

Option D is wrong because primary key naming is a metadata label; renaming or omitting a constraint name has no effect on whether the DDL executes or the data loads.

51
MCQmedium

A data engineer is designing a database for a sensor network that generates 20,000 readings per second. The schema is fixed, and each reading must be stored with minimal write latency while preserving the exact order of arrival for later time-series analysis. Which database structure should the engineer choose?

A.Document store with each sensor's readings embedded in a single growing document
B.Append-only log-structured store keyed by timestamp and sensor ID
C.Graph database with sensor nodes connected by reading edges
D.Relational table with a composite primary key on sensor ID and timestamp
AnswerB

An append-only log-structured store writes sequentially to disk, avoiding random I/O and in-place index updates, which keeps write latency low at high ingest rates. Keying entries by timestamp and sensor ID preserves arrival order and enables efficient range scans for time-series analysis, directly satisfying both the throughput and ordering requirements described.

Why this answer

The scenario demands high-throughput, low-latency ingestion with preserved arrival order. An append-only log-structured store achieves this by writing sequentially and keying entries by timestamp and sensor ID, which supports both fast writes and efficient time-range reads. Relational, document, and graph structures each introduce overhead or modeling mismatches that prevent meeting the stated performance and ordering requirements.

Exam trap

The trap here is assuming that a relational table with a timestamp column automatically provides the write performance and ordering guarantees of an append-only log-structured store.

52
MCQmedium

What is the primary purpose of a 'Normalization' process in database design?

A.Convert SQL to NoSQL
B.Reduce redundancy
C.Increase query speed
D.Enable horizontal scaling
AnswerB

Normalisation structures tables so each fact is stored once, eliminating duplicate data and the update, insert and delete anomalies that duplication causes. This directly satisfies the stem's requirement to reduce redundancy, unlike indexing or denormalisation, which address query speed rather than data duplication.

Why this answer

Normalization is the process of organizing database tables to minimize redundancy and dependency by dividing large tables into smaller, related ones and defining relationships. Its primary purpose is to reduce data duplication and prevent update, insert, and delete anomalies.

Exam trap

DS0-001 often tests the primary purpose of normalization, and candidates may incorrectly associate it with performance improvement or scaling, when in fact normalization primarily reduces redundancy and anomalies, sometimes at the cost of query speed.

How to eliminate wrong answers

Option A is wrong because normalization is a relational design technique and has nothing to do with converting SQL to NoSQL. Option C is wrong because normalization often reduces query speed due to additional joins; denormalization is used to improve read performance. Option D is wrong because horizontal scaling is a distributed systems concern, not the goal of normalization, which focuses on logical data integrity.

53
Multi-Selectmedium

Which THREE of the following are benefits of database indexing?

Select 3 answers
A.Enforcement of uniqueness
B.Faster data retrieval
C.Optimization of JOIN operations
D.Faster write operations
E.Reduced storage requirements
AnswersA, B, C

A unique index physically enforces uniqueness by rejecting duplicate key values at insert or update, satisfying the constraint that no two rows share the same value. This differs from a plain non-unique index, which merely accelerates lookups without restricting data, so uniqueness is guaranteed by the index itself rather than application logic.

Why this answer

Option A (Enforcement of uniqueness) is correct because a UNIQUE index (or a PRIMARY KEY constraint, which is backed by a unique index) forces the database engine to reject any duplicate values in the indexed column(s), guaranteeing data integrity. Option B (Faster data retrieval) is correct because an index provides a sorted, balanced-tree (B-tree) or hash structure that lets the query optimizer locate rows with index seeks instead of scanning the entire table, dramatically reducing I/O for SELECT and WHERE predicates. Option C (Optimization of JOIN operations) is correct because indexes on join columns allow the optimizer to perform efficient nested-loop, hash, or merge joins by probing the indexed key rather than scanning full tables.

Option D (Faster write operations) is not a benefit: every INSERT, UPDATE, or DELETE must also maintain the index entries, adding overhead and slowing writes. Option E (Reduced storage requirements) is not a benefit: indexes consume additional disk space and memory, increasing rather than reducing storage needs.

Exam trap

The trap is assuming indexes speed up everything; the exam expects you to recognize that indexes penalize writes and consume storage, so those two options are distractors.

54
MCQhard

A database administrator is investigating performance degradation during heavy concurrent write operations. Which isolation level provides the highest level of data consistency but the lowest concurrency?

A.Read Committed
B.Repeatable Read
C.Serializable
D.Read Uncommitted
AnswerC

Serializable is the strictest isolation level, using range locks and predicate locking to make concurrent transactions behave as if run sequentially. This guarantees the highest consistency but forces blocking, giving the lowest concurrency under heavy writes.

Why this answer

Serializable is the highest isolation level, ensuring complete isolation from other transactions. It prevents dirty reads, non-repeatable reads, and phantom reads, but at the cost of lowest concurrency due to increased locking and potential blocking.

Exam trap

DS0-001 often tests the trade-off between isolation levels and concurrency, and candidates may incorrectly assume that higher consistency always means better performance.

How to eliminate wrong answers

Option A is wrong because Read Committed prevents dirty reads but allows non-repeatable reads and phantom reads, offering lower consistency than Serializable. Option B is wrong because Repeatable Read prevents non-repeatable reads but can allow phantom reads, and it has higher concurrency than Serializable. Option D is wrong because Read Uncommitted is the lowest isolation level, allowing dirty reads and providing the least consistency.

55
Multi-Selectmedium

Which THREE of the following are common SQL constraints?

Select 3 answers
A.GROUP BY
B.JOIN
C.PRIMARY KEY
D.UNIQUE
E.CHECK
AnswersC, D, E

PRIMARY KEY enforces entity integrity by uniquely identifying each row and implicitly forbidding NULLs, making it a standard SQL constraint alongside FOREIGN KEY, UNIQUE, CHECK and NOT NULL. It satisfies the stem's requirement for a common constraint used to guarantee row-level uniqueness.

Why this answer

PRIMARY KEY (C) is a common SQL constraint that uniquely identifies each row in a table and implicitly enforces NOT NULL and uniqueness. UNIQUE (D) is a common SQL constraint that ensures all values in a column or set of columns are distinct, though it typically permits NULL values. CHECK (E) is a common SQL constraint that restricts the values a column can accept based on a Boolean expression, such as CHECK (age >= 18).

GROUP BY (A) is a SELECT clause used for aggregating rows into groups, not a constraint, and JOIN (B) is a query operation that combines rows from two or more tables, also not a constraint.

Exam trap

DS0-001 often tests the confusion between SQL clauses (GROUP BY, JOIN, WHERE) and declarative constraints — candidates who don't separate query syntax from schema-level integrity rules pick clauses as constraints.

56
MCQmedium

Which SQL clause is used to sort the result of a query by one or more columns?

A.ORDER BY
B.SORT BY
C.ARRANGE BY
D.GROUP BY
AnswerA

ORDER BY sorts the result set by one or more specified columns, ascending by default or descending with DESC. It is the SQL clause that satisfies the requirement to sort query output, applied after WHERE and before any row-limiting clause.

Why this answer

The ORDER BY clause in SQL is the standard, ANSI-defined mechanism for sorting the result set of a SELECT statement by one or more columns, in ascending (ASC, the default) or descending (DESC) order. It is applied after the result set is produced and can reference column names, aliases, or positional ordinals. No other clause in standard SQL performs result-set sorting.

Exam trap

The trap here is the plausible-sounding but non-existent clauses SORT BY and ARRANGE BY — candidates who have seen Hive or Spark SQL may incorrectly accept SORT BY as standard, and GROUP BY is confused with sorting because grouped output sometimes appears ordered.

How to eliminate wrong answers

Option B is wrong because SORT BY is not a valid SQL clause — it is a Hive/Spark SQL extension used for sorting within partitions, not standard SQL, and would raise a syntax error in a standard relational database. Option C is wrong because ARRANGE BY is not a SQL keyword at all; it is a fabricated clause with no meaning in any SQL dialect. Option D is wrong because GROUP BY aggregates rows into groups for use with aggregate functions like COUNT, SUM, and AVG — it does not sort the output, and any apparent ordering is coincidental and not guaranteed.

57
MCQmedium

A data engineer is reviewing a table that stores customer support tickets. The table has a column TicketID defined as an IDENTITY column and a column CreatedDate defined as DATETIME2 with a DEFAULT constraint of SYSDATETIME(). During a bulk insert of 500 rows, the engineer notices that all 500 rows received the exact same CreatedDate value, but each TicketID is unique and sequential. What is the most likely explanation for the identical CreatedDate values?

A.The IDENTITY property forces all other columns to use the same default value for referential integrity.
B.DATETIME2 has a precision of one second, so all rows inserted within the same second appear identical.
C.SYSDATETIME() is nondeterministic and is evaluated once per statement, so all rows in the same INSERT statement get the same value.
D.The DEFAULT constraint is evaluated once per batch, not once per row.
AnswerC

SYSDATETIME() is a nondeterministic function, and within a single INSERT statement it is evaluated once, then the same value is applied to all rows. This is a documented behavior for nondeterministic functions used in DEFAULT constraints during multi-row inserts. To get per-row timestamps, you would need a different approach such as a trigger or application-supplied values.

Why this answer

Nondeterministic functions such as SYSDATETIME() used in a DEFAULT constraint are evaluated once per INSERT statement, and the resulting value is applied to every row in that statement. This is why all 500 rows share the same CreatedDate even though they were inserted together. The IDENTITY column still generates unique values because it is a separate mechanism.

To obtain distinct timestamps per row, you would need a trigger, an application-generated value, or a row-by-row insert.

Exam trap

The trap here is assuming that a DEFAULT constraint is evaluated per row for every function, when nondeterministic functions like SYSDATETIME() are actually evaluated once per statement.

58
MCQmedium

A data engineer is designing a table in a relational database to store product inventory records. The business requires that the combination of 'ProductCode' and 'WarehouseID' uniquely identifies each row, and that no duplicate pairs are allowed. Which constraint should be applied to enforce this requirement?

A.PRIMARY KEY on ProductCode and WarehouseID combined
B.FOREIGN KEY referencing the Product and Warehouse tables
C.UNIQUE constraint on ProductCode only
D.CHECK constraint comparing ProductCode and WarehouseID
AnswerA

A composite PRIMARY KEY enforces uniqueness across the combination of ProductCode and WarehouseID and implicitly disallows NULLs, which matches the requirement that each pair uniquely identifies a row. It also creates a unique index that the database engine uses to reject duplicate pairs, ensuring entity integrity for the inventory table.

Why this answer

A composite PRIMARY KEY on ProductCode and WarehouseID is the correct choice because it enforces uniqueness of the combination and disallows NULLs, exactly matching the requirement that each pair uniquely identifies an inventory row. Other constraints either enforce referential integrity, validate row-level conditions, or apply uniqueness too narrowly.

Exam trap

The trap here is confusing referential integrity with entity integrity, assuming a FOREIGN KEY can enforce uniqueness of a composite identifier.

59
Multi-Selectmedium

Which THREE of the following are components of a database connection string?

Select 3 answers
A.Operating system version
B.Server address
C.Database name
D.Credentials
E.CPU core count
AnswersB, C, D

The server address identifies the host — by name or IP, often with a port or instance — that the client must reach. It is one of the three essential components, since without it the provider cannot locate the database engine to connect to.

Why this answer

A database connection string must identify where the database lives, so option B (Server address) is correct — it supplies the host name or IP plus, typically, the port or instance name (e.g., 'Server=myhost\SQLEXPRESS' or 'Data Source=10.0.0.5,1433'). Option C (Database name) is correct because the string usually specifies the target catalog to connect to, such as 'Database=SalesDB' or 'Initial Catalog=SalesDB'. Option D (Credentials) is correct because authentication details — a username/password pair or an indication to use integrated/Windows authentication — are standard connection-string elements (e.g., 'User ID=sa;Password=...' or 'Integrated Security=True').

Option A (Operating system version) is not part of a connection string, since the client OS is irrelevant to the connection parameters, and option E (CPU core count) is a hardware attribute that has no place in connection-string syntax.

Exam trap

DS0-001 often tests whether candidates can distinguish connection-string parameters from environmental or hardware attributes — the trap is selecting OS version or CPU count because they sound like deployment considerations, when in fact they never appear in a connection string.

Ready to test yourself?

Try a timed practice session using only Database Structures And SQL questions.