OA Exams

  • web.groovymark@gmail.com
  • December 10, 2024

Question 01

Which SQL clause is used to retrieve data from a database table?

a) INSERT
b) SELECT
c) DELETE
d) UPDATE

Correct Answer: b) SELECT

Explanation: The SELECT clause is used in SQL to query and retrieve data from a database table. INSERT adds new rows, DELETE removes rows, and UPDATE modifies existing rows.

Question 02

In a relational database, what is a tuple?

a) An unordered collection of elements
b) An ordered collection of elements
c) A key-value pair
d) A relationship between two tables

Correct Answer: b) An ordered collection of elements

Explanation: In a relational database, a tuple represents a single row in a table and is an ordered collection of elements. Unordered collections are sets, key-value pairs are used in NoSQL databases, and relationships between tables are managed through keys.

Question 03

What SQL command is used to delete a table from a database?

a) DELETE
b) TRUNCATE
c) DROP
d) ALTER

Correct Answer: c) DROP

Explanation: The DROP command is used to completely remove a table from the database. DELETE removes rows from a table, TRUNCATE clears all rows but keeps the table structure, and ALTER modifies the structure of a table.

Question 04

Which relational operation eliminates one or more columns of a table?

a) SELECT
b) PROJECT
c) JOIN
d) UNION

Correct Answer: b) PROJECT

Explanation: The PROJECT operation is used to select specific columns of a table, eliminating the others. SELECT retrieves rows, JOIN combines tables based on a condition, and UNION merges two tables into one.

Question 05

Which SQL keyword is used to rename a column or table in a query result?

a) AS
b) FROM
c) RENAME
d) ALIAS

Correct Answer: a) AS

Explanation: The AS keyword is used to rename columns or tables in SQL query results. FROM specifies the table, RENAME is not used in query results, and ALIAS is a general term for renaming but not a keyword.

Question 06

 In SQL, what does the GROUP BY clause do?

a) Groups rows that have the same values in specified columns
b) Orders the result set in ascending order
c) Filters rows based on a condition
d) Removes duplicate rows from the result set

Correct Answer: a) Groups rows that have the same values in specified columns

Explanation: The GROUP BY clause groups rows that share values in specified columns, often used with aggregate functions. ORDER BY sorts the result set, WHERE filters rows, and DISTINCT removes duplicates.

Question 07

Which of the following is a binary operation in relational algebra?

a) SELECT
b) PROJECT
c) PRODUCT
d) RENAME

Correct Answer: c) PRODUCT

Explanation: The PRODUCT operation in relational algebra combines all rows from two tables. SELECT and PROJECT are unary operations, while RENAME changes table or column names.

Question 08

Which of the following SQL clauses is used to filter records?

a) WHERE
b) SELECT
c) GROUP BY
d) ORDER BY

Correct Answer: a) WHERE

Explanation: The WHERE clause is used to filter records based on a specified condition. SELECT retrieves data, GROUP BY groups rows, and ORDER BY sorts the result set.

Question 09

What is a primary key in a relational database?

a) A column that contains unique values for each row
b) A column that can contain duplicate values
c) A column that refers to another table
d) A column that stores binary data

Correct Answer: a) A column that contains unique values for each row

Explanation: A primary key uniquely identifies each row in a table. It cannot contain duplicate values, while foreign keys refer to other tables, and binary data is not related to primary keys.

Question 10

In SQL, which command is used to create a new table?

a) CREATE DATABASE
b) CREATE TABLE
c) ALTER TABLE
d) INSERT INTO

Correct Answer: b) CREATE TABLE

Explanation: The CREATE TABLE command is used to create a new table in a database. CREATE DATABASE creates a new database, ALTER TABLE modifies an existing table, and INSERT INTO adds data to a table.

Question 11

Which of the following aggregate functions counts the number of rows in a table?

a) SUM()
b) COUNT()
c) AVG()
d) MAX()

Correct Answer: b) COUNT()

Explanation: The COUNT() function returns the number of rows in a table. SUM() adds numeric values, AVG() calculates the average, and MAX() returns the maximum value.

Question 12

What is the role of the FOREIGN KEY in a relational database?

a) Uniquely identifies a row in a table
b) Links rows from two tables based on a related column
c) Represents a temporary table
d) Stores binary data

Correct Answer: b) Links rows from two tables based on a related column

Explanation: A foreign key links rows in two tables by referencing a primary key in another table. A primary key uniquely identifies rows, while binary data and temporary tables are unrelated to foreign keys.

Question 13

Which SQL statement is used to change data in an existing row?

a) INSERT
b) DELETE
c) UPDATE
d) SELECT

Correct Answer: c) UPDATE

Explanation: The UPDATE statement is used to modify existing data in a row. INSERT adds new rows, DELETE removes rows, and SELECT retrieves data without modification.

Question 14

What does the HAVING clause do in SQL?

a) Filters rows based on aggregate functions
b) Filters rows based on a condition before aggregation
c) Sorts rows in descending order
d) Removes duplicate rows

Correct Answer: a) Filters rows based on aggregate functions

Explanation: The HAVING clause filters rows after aggregation, commonly used with GROUP BY. WHERE filters rows before aggregation, and ORDER BY sorts rows. DISTINCT removes duplicate rows.

Question 15

Which of the following is a volatile memory type?

a) Hard disk drive
b) Flash memory
c) RAM
d) Magnetic tape

Correct Answer: c) RAM

Explanation: RAM is volatile memory, meaning its data is lost when power is turned off. Hard drives, flash memory, and magnetic tapes are non-volatile, retaining data without power.

Question 16

In the context of databases, what is normalization?

a) The process of speeding up queries
b) The process of organizing data to reduce redundancy
c) The process of increasing the storage capacity
d) The process of filtering data based on conditions

Correct Answer: b) The process of organizing data to reduce redundancy

Explanation: Normalization organizes data in a way that reduces redundancy and ensures data integrity. It is unrelated to query speed, storage capacity, or data filtering.

Question 17

What is a database transaction?

a) A single query execution
b) A sequence of one or more SQL operations treated as a single unit
c) The process of filtering data
d) A method to optimize query performance

Correct Answer: b) A sequence of one or more SQL operations treated as a single unit

Explanation: A transaction in a database is a sequence of operations performed as a single logical unit. Transactions ensure data integrity and consistency. Queries and filtering are individual operations, while query optimization is unrelated.

Question 18

Which of the following is an example of an aggregate function?

a) IFNULL()
b) COUNT()
c) CONCAT()
d) SUBSTRING()

Correct Answer: b) COUNT()

Explanation: COUNT() is an aggregate function that returns the number of rows in a result set. IFNULL() handles null values, CONCAT() concatenates strings, and SUBSTRING() extracts a portion of a string.

Question 19

What does the JOIN clause do in SQL?

a) Combines rows from two or more tables based on a related column
b) Removes rows from a table
c) Renames a column or table
d) Groups rows based on a condition

Correct Answer: a) Combines rows from two or more tables based on a related column

Explanation: The JOIN clause combines rows from different tables based on a related column. It does not delete rows, rename columns or tables, or group rows.

Question 20

Which type of join returns only matching rows from both tables?

a) LEFT JOIN
b) RIGHT JOIN
c) FULL JOIN
d) INNER JOIN

Correct Answer: d) INNER JOIN

Explanation: An INNER JOIN returns only rows that have matching values in both tables. LEFT JOIN returns all rows from the left table, RIGHT JOIN returns all rows from the right table, and FULL JOIN returns all rows from both tables.

Complete the Captcha to view next question set.

Tags

Prev Post
WGU D492 Practice Exam Questions – Set 1 – Part 2
Next Post
WGU D377 Practice Exam Questions – Set 4 – Part 2