Which SQL operator is used to compare a value to a range of values?
a) IN b) BETWEEN c) LIKE d) EXISTS
Correct Answer: b) BETWEEN
Explanation: The BETWEEN operator is used to compare a value to a range of values, specifying a minimum and maximum value in a query.
Question 42
Which SQL function calculates the number of rows returned by a query?
a) COUNT() b) SUM() c) AVG() d) MAX()
Correct Answer: a) COUNT()
Explanation: The COUNT() function returns the number of rows in a result set, often used to determine how many rows meet certain criteria.
Question 43
What is the primary function of a Unique Key in a database table?
a) To allow duplicate rows in a table b) To store multiple values in one row c) To ensure that a column has unique values d) To link two tables together
Correct Answer: c) To ensure that a column has unique values
Explanation: A Unique Key ensures that all values in a specified column or set of columns are distinct, preventing duplicate entries.
Question 44
Which aggregate function in SQL calculates the average of values in a column?
a) AVG() b) SUM() c) MIN() d) COUNT()
Correct Answer: a) AVG()
Explanation: The AVG() function calculates the arithmetic mean (average) of the values in a specified column.
Question 45
In relational databases, what does the term “entity” refer to?
a) A relationship between two tables b) A set of related columns c) A real-world object or concept represented in a table d) A key used to identify rows
Correct Answer: c) A real-world object or concept represented in a table
Explanation: An entity represents a real-world object, person, or concept in a relational database, typically modeled as a table with attributes.
Question 46
Which SQL statement is used to change the values of existing rows in a table?
a) INSERT b) UPDATE c) DELETE d) SELECT
Correct Answer: b) UPDATE
Explanation: The UPDATE statement is used to modify the values of existing rows in a table, typically by specifying new values for certain columns.
Question 47
Which SQL operator is used to filter results based on matching patterns in a text field?
a) IN b) BETWEEN c) LIKE d) EXISTS
Correct Answer: c) LIKE
Explanation: The LIKE operator is used in SQL to filter rows based on matching patterns in a text field, often used with wildcards like % and _.
Question 48
Which type of key is used to uniquely identify each row in a table and must contain unique, non-null values?
a) Foreign Key b) Primary Key c) Unique Key d) Composite Key
Correct Answer: b) Primary Key
Explanation: A Primary Key is used to uniquely identify each row in a table and must contain unique, non-null values to ensure data integrity.
Question 49
Which type of join returns rows from the left table and matching rows from the right table, filling in NULLs where there is no match?
a) LEFT JOIN b) FULL JOIN c) RIGHT JOIN d) INNER JOIN
Correct Answer: a) LEFT JOIN
Explanation: A LEFT JOIN returns all rows from the left table and matching rows from the right table, filling in NULL values where there is no match.
Question 50
In relational databases, which constraint ensures that a foreign key value must match an existing primary key value or be NULL?
a) CHECK b) Referential Integrity c) UNIQUE d) PRIMARY KEY
Correct Answer: b) Referential Integrity
Explanation: Referential Integrity ensures that foreign key values in a table must either match an existing primary key value or be NULL, maintaining relationships between tables.