Courseiva

CCNA Database Structures And Sql Questions

40 questions · Database Structures And Sql topic · 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

FOREIGN KEY enforces referential integrity between tables.

Why this answer

A foreign key constraint ensures referential integrity between two tables by requiring that the value in the child table exists in the parent table.

2
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 entire structure.

Why this answer

The DROP TABLE statement removes the definition and all data within the table permanently.

3
MCQmedium

A transaction involves multiple updates that must either all succeed or all fail. Which command ensures this behavior?

A.GRANT
B.SAVEPOINT
C.BEGIN
D.COMMIT
AnswerD

COMMIT is the command that confirms and saves a transaction.

Why this answer

COMMIT finalizes the transaction, while ROLLBACK reverts it; together they ensure atomicity.

4
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 can automatically inject a timestamp during an INSERT.

Why this answer

A trigger is a database object that automatically executes code when a specific event (like INSERT) occurs on a table.

5
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

Used to remove objects.

Why this answer

CREATE and DROP are DDL commands used to define or modify database structures.

6
Multi-Selectmedium

Which THREE of the following are considered ACID properties in database transactions?

Select 3 answers
A.Atomicity
B.Scalability
C.Consistency
D.Availability
E.Isolation
AnswersA, C, E

All or nothing operation.

Why this answer

ACID stands for Atomicity, Consistency, Isolation, and Durability.

7
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

It is the standard for RDBMS.

Why this answer

SQL is a standard language for relational databases, and DML is used for data manipulation.

8
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

An index provides a direct path to the data.

Why this answer

A Table Scan occurs when the database must read every row; an index would allow it to find data more efficiently.

9
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 is the correct command to add a column.

Why this answer

The ALTER TABLE command is used to modify the structure of an existing table, such as adding a new column.

10
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

Consistent locking order prevents deadlocks.

Why this answer

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

11
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 effectively clears all data in a table.

Why this answer

TRUNCATE is a DDL operation that removes all records from a table and is generally faster than DELETE because it does not log individual row deletions.

12
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

Calculates the average of values.

Why this answer

SUM, AVG, and COUNT are standard aggregate functions used in SQL.

13
MCQeasy

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

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

UPDATE is the correct DML statement for editing records.

Why this answer

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

14
MCQeasy

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

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

LIKE supports pattern matching with wildcards.

Why this answer

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

15
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 is specifically designed to accelerate data retrieval.

Why this answer

An index allows the database engine to find specific rows without scanning the entire table, significantly improving read performance.

16
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 stacks results of multiple queries.

Why this answer

The UNION operator is specifically designed to combine the result sets of two or more SELECT statements into one.

17
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 removes duplicates from the output.

Why this answer

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

18
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

Stores data as simple pairs.

Why this answer

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

19
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 handle running totals efficiently.

Why this answer

Window functions, specifically SUM() OVER(), allow calculations across a set of rows related to the current row without collapsing the result into a single group.

20
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 offer strong logical isolation.

Why this answer

Using a separate schema or database per tenant provides a hard boundary that prevents cross-tenant data access.

21
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

LEFT JOIN preserves all records from the left source.

Why this answer

A LEFT JOIN returns all rows from the left table, and matching rows from the right table; if no match exists, NULL values are returned for right-side columns.

22
MCQeasy

Which command is used to restrict a user's access to a specific table?

A.DENY
B.REVOKE
C.DROP
D.REMOVE
AnswerB

REVOKE is the standard DCL command to remove access.

Why this answer

REVOKE is the DCL command used to remove permissions previously granted to a user.

23
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

Encapsulates logic for reuse.

Why this answer

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

24
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

Views are frequently used to restrict access to sensitive table data.

Why this answer

A view can be used to expose only specific columns to a user or group, effectively hiding sensitive data like salaries.

25
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 is the correct clause to filter aggregated group results.

Why this answer

The HAVING clause is used to filter groups created by the GROUP BY clause, whereas WHERE filters individual rows.

26
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 excel at managing complex relationships.

Why this answer

Graph databases are specifically designed for data that is highly interconnected, such as social networks.

27
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

Helps the optimizer plan queries.

Why this answer

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

28
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 databases provide the flexibility for unstructured data and distributed horizontal scaling.

Why this answer

NoSQL databases, such as document stores, are designed for horizontal scaling and handling unstructured data, unlike rigid relational schemas.

29
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

ACID compliance is a core requirement for financial systems.

Why this answer

Relational databases provide strong ACID compliance, which is essential for financial transactions where data integrity is paramount.

30
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

DMVs are designed for monitoring server state and connections.

Why this answer

Most RDBMS provide dynamic management views (like sys.dm_exec_sessions in SQL Server) to monitor server health and connections.

31
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

Returns all left rows.

Why this answer

INNER, LEFT, and FULL are all standard SQL join types.

32
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

Updates may cause inconsistencies.

Why this answer

Denormalization can lead to data anomalies (inconsistencies) and increased storage usage due to redundancy.

33
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

Data type mismatch is a critical technical failure point.

Why this answer

Data types can vary significantly between RDBMS vendors, leading to truncation or conversion errors if not mapped correctly during migration.

34
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

Minimizing data duplication is the goal of normalization.

Why this answer

Normalization minimizes redundancy and dependency by organizing fields and table relationships, which reduces data anomalies.

35
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

Unique indexes prevent duplicates.

Why this answer

Indexing speeds up data retrieval, improves JOIN performance, and aids in uniqueness enforcement.

36
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 provides the highest consistency by preventing all concurrency-related anomalies.

Why this answer

Serializable isolation ensures that concurrent transactions result in a state that could have been achieved if transactions were executed serially, preventing all phenomena but reducing concurrency.

37
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

Ensures unique row identification.

Why this answer

PRIMARY KEY, UNIQUE, and CHECK are standard SQL constraints used to maintain data integrity.

38
MCQmedium

A business user needs to calculate the average age of customers, but some age fields are NULL. Which function should be used to treat NULL as 0?

A.NULLIF
B.IFNULL
C.COALESCE
D.ISNULL
AnswerC

COALESCE is the standard SQL function for handling NULLs.

Why this answer

The COALESCE function returns the first non-null expression in the list, allowing NULLs to be replaced with 0.

39
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 query results.

Why this answer

The ORDER BY clause is used to sort the result set in ascending or descending order.

40
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

Identifies the host.

Why this answer

Server address, database name, and authentication credentials are all standard components of a connection string.

Ready to test yourself?

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