Objective Assessment Study Guide, Data Management Applications Exam
Prep, MySQL, SQL Queries, Joins, Subqueries, DDL, DML, Database Design,
Tables, Views, Primary Keys, Foreign Keys, Indexes, Practice Questions,
Answers & Rationales
Question 1: Which SQL clause is used to filter rows before they are grouped by
an aggregate function?
A. HAVING
B. WHERE
C. GROUP BY
D. ORDER BY
CORRECT ANSWER: B. WHERE
Rationale: The WHERE clause filters individual rows before any grouping or
aggregation occurs. The HAVING clause filters groups after the GROUP BY clause
has been applied. GROUP BY creates groups of rows, and ORDER BY sorts the final
output.
Question 2: What is the default sort order of the ORDER BY clause if no direction
is specified?
A. Descending
B. Ascending
C. Random
D. No default; it throws an error
CORRECT ANSWER: B. Ascending
Rationale: The default behavior of the ORDER BY clause is to sort results in
ascending (ASC) order, from the smallest value to the largest, or from A to Z for
strings.
Question 3: A table has 100 rows. You run the query SELECT COUNT(*) FROM
employees;. If 5 rows contain NULL values in the salary column, what is
returned?
A. 95
B. 100
,C. An error
D. 0
CORRECT ANSWER: B. 100
Rationale: The COUNT(*) function counts the total number of rows in a table,
regardless of NULL values in any column. If the query were COUNT(salary), it
would exclude the 5 rows with NULL values and return 95.
Question 4: Which wildcard character matches exactly one single character in a
SQL LIKE clause?
A. %
B. *
C. _ (underscore)
D. ?
CORRECT ANSWER: C. _ (underscore)
Rationale: In SQL, the underscore (_) wildcard matches exactly one character. The
percent sign (%) matches zero or more characters. The asterisk (*) and question
mark (?) are used in other contexts but are not standard SQL wildcards for the
LIKE operator.
Question 5: Which operator is used in SQL to combine rows from two or more
tables based on a related column between them?
A. UNION
B. SELECT
C. JOIN
D. WHERE
CORRECT ANSWER: C. JOIN
Rationale: The JOIN clause combines rows from two or more tables based on a
related column between them. UNION combines results from multiple SELECT
statements vertically. SELECT retrieves data from a table, and WHERE filters
conditions on individual rows.
Question 6: What is the result of the mathematical expression SELECT ; in
MySQL?
,A. 3
B. 3.75
C. 4
D. 3.75 with rounding error
CORRECT ANSWER: B. 3.75
Rationale: In MySQL, the division operator (/) returns a decimal result. Therefore,
evaluates to 3.75. To return an integer result, the DIV operator would be
used (15 DIV 4 = 3).
Question 7: Which SQL statement is used to remove all rows from a table
without deleting the table structure?
A. DELETE * FROM table_name
B. DROP TABLE table_name
C. TRUNCATE TABLE table_name
D. REMOVE TABLE table_name
CORRECT ANSWER: C. TRUNCATE TABLE table_name
Rationale: TRUNCATE deletes all rows while preserving the table structure and
resets any auto-increment counters. DELETE without a WHERE clause also
removes all rows but logs individual row deletions and does not reset identity.
DROP removes the entire table.
Question 8: In a database, a primary key constraint ensures that a column
contains:
A. Unique values only
B. Unique and NOT NULL values
C. Only numeric values
D. A default value
CORRECT ANSWER: B. Unique and NOT NULL values
Rationale: A primary key uniquely identifies each row and cannot contain NULLs.
Unique constraints allow NULLs (unless also NOT NULL). A primary key is a
combination of uniqueness and mandatory data.
, Question 9: An Entity-Relationship (ER) diagram uses a diamond shape to
represent a:
A. Entity
B. Attribute
C. Relationship
D. Key constraint
CORRECT ANSWER: C. Relationship
Rationale: In ER diagrams, entities are rectangles, attributes are ovals, and
relationships are diamonds. The diamond connects related entities and often
contains a verb describing the association.
Question 10: Which SQL keyword is used to sort the result set in descending
order?
A. SORT DESC
B. ORDER BY DESC
C. ORDER BY column_name DESC
D. GROUP BY DESC
CORRECT ANSWER: C. ORDER BY column_name DESC
Rationale: The ORDER BY clause sorts rows; ASC is the default. Using ORDER BY
column DESC returns rows from highest to lowest. SORT is not a valid SQL
command.
Question 11: Normalization to third normal form (3NF) eliminates:
A. Partial dependencies
B. Transitive dependencies
C. Repeating groups
D. Multivalued dependencies
CORRECT ANSWER: B. Transitive dependencies
Rationale: 3NF requires that every non-prime attribute is non-transitively
dependent on the primary key. 1NF removes repeating groups; 2NF removes
partial dependencies; 3NF removes transitive dependencies.