- web.groovymark@gmail.com
- October 24, 2024
Question 01
Which normal form ensures that every cell contains exactly one value and every table has a primary key?
a) First Normal Form (1NF)
b) Second Normal Form (2NF)
c) Third Normal Form (3NF)
d) Boyce-Codd Normal Form (BCNF)
Correct Answer: a) First Normal Form (1NF)
Explanation: First Normal Form (1NF) ensures that every cell contains exactly one value and that the table has a primary key. This is the most basic form of database normalization.
Question 02
In SQL, which keyword is used to prevent a column from having a NULL value?
a) NOT NULL
b) DEFAULT
c) AUTO_INCREMENT
d) PRIMARY KEY
Correct Answer: a) NOT NULL
Explanation: The NOT NULL keyword is used to ensure that a column does not accept NULL values. It is added in the column definition during table creation.
Question 03
Which type of join in SQL selects all rows from the left table and only matching rows from the right table?
a) INNER JOIN
b) FULL JOIN
c) LEFT JOIN
d) CROSS JOIN
Correct Answer: c) LEFT JOIN
Explanation: A LEFT JOIN selects all rows from the left table and only the matching rows from the right table. Rows from the left table without a match in the right table will have NULLs in the columns from the right table.
Question 04
Which SQL operator is used to compare columns using the = operator?
a) NON-EQUIJOIN
b) CROSS JOIN
c) SELF JOIN
d) EQUIJOIN
Correct Answer: d) EQUIJOIN
Explanation: An EQUIJOIN is used to compare columns using the = operator in SQL. It is the most common type of join where two tables are joined based on equality between specified columns.
Question 05
Which type of key in a table uniquely identifies a row and cannot be NULL?
a) Foreign Key
b) Composite Key
c) Primary Key
d) Unique Key
Correct Answer: c) Primary Key
Explanation: A Primary Key uniquely identifies each row in a table and must always have unique, non-NULL values.
Question 06
In database design, which phase specifies the structure and organization of the database tables?
a) Conceptual Design
b) Physical Design
c) Logical Design
d) Data Definition
Correct Answer: b) Physical Design
Explanation: Physical Design specifies how the database tables are organized on storage media, including indexes and partitions, to optimize query performance.
Question 07
Which type of index contains an entry for every row in a table?
a) Sparse Index
b) Dense Index
c) Primary Index
d) Multi-level Index
Correct Answer: b) Dense Index
Explanation: A Dense Index contains an entry for every row in the table, unlike a Sparse Index, which contains entries for only certain rows or blocks.
Question 08
In relational databases, what does the term “cardinality” refer to?
a) The speed of data access
b) The number of times an entity can be related to another entity
c) The type of join used between tables
d) The process of normalizing data
Correct Answer: b) The number of times an entity can be related to another entity
Explanation: Cardinality refers to the maximum and minimum number of times one entity can be related to instances of another entity in a relational database. conversion funnel outlines the stages users go through on their way to completing a goal, such as making a purchase or signing up for a newsletter.
Question 09
Which SQL statement is used to create a new table in a database?
a) CREATE INDEX
b) CREATE TABLE
c) INSERT INTO
d) ALTER TABLE
Correct Answer: b) CREATE TABLE
Explanation: The CREATE TABLE statement is used to define and create a new table by specifying its column names, data types, and constraints. pack displays a group of nearby businesses relevant to a user’s query, often alongside a map, and appears in organic search results.
Question 10
Which type of relationship is defined when a foreign key in one table refers to the primary key of another table?
a) One-to-Many
b) One-to-One
c) Many-to-Many
d) Self-Join
Correct Answer: a) One-to-Many
Explanation: A One-to-Many relationship is established when a foreign key in one table refers to the primary key in another table, allowing multiple rows in the first table to relate to a single row in the second.
Question 11
Which SQL function returns the minimum value in a set of rows?
a) MAX()
b) MIN()
c) SUM()
d) COUNT()
Correct Answer: b) MIN()
Explanation: The MIN() function returns the smallest value from a set of rows in SQL. It is often used to find the minimum value in a numeric column.
Question 12
What is the primary purpose of the TRUNCATE statement in SQL?
a) Deletes a single row
b) Deletes all rows from a table
c) Deletes a column from a table
d) Deletes a table structure
Correct Answer: b) Deletes all rows from a table
Explanation: The TRUNCATE statement in SQL is used to remove all rows from a table but keeps the table structure intact for future use.
Question 13
Which database object is used to define rules that enforce data integrity, such as preventing invalid values?
a) Index
b) Constraint
c) View
d) Trigger
Correct Answer: b) Constraint
Explanation: Constraints are rules defined on columns to enforce data integrity, ensuring that only valid data is inserted, updated, or deleted.
Question 14
What is the key characteristic of an AUTO_INCREMENT column in SQL?
a) It must be a text column.
b) It is automatically assigned a unique number for each row.
c) It cannot be updated once inserted.
d) It allows NULL values.
Correct Answer: b) It is automatically assigned a unique number for each row.
Explanation: An AUTO_INCREMENT column automatically generates a unique, sequential number for each new row inserted into the table.
Question 15
In which normal form are all non-key columns dependent on the whole primary key and nothing else?
a) First Normal Form (1NF)
b) Second Normal Form (2NF)
c) Third Normal Form (3NF)
d) Boyce-Codd Normal Form (BCNF)
Correct Answer: c) Third Normal Form (3NF)
Explanation: Third Normal Form (3NF) requires that all non-key columns depend on the primary key and no other non-key column.
Question 16
Which SQL clause is used to filter results based on a condition?
a) SELECT
b) FROM
c) WHERE
d) JOIN
Correct Answer: c) WHERE
Explanation: The WHERE clause filters the results returned by a query based on the specified condition, such as comparing column values.
Question 17
Which type of index only stores entries for certain blocks of a table rather than every row?
a) Dense Index
b) Sparse Index
c) Hash Index
d) Bitmap Index
Correct Answer: b) Sparse Index
Explanation: A Sparse Index stores entries only for certain blocks of a table, making it more efficient for larger datasets where not every row needs to be indexed.
Question 18
Which type of join returns rows that have matching values in both the left and right tables?
a) INNER JOIN
b) LEFT JOIN
c) RIGHT JOIN
d) FULL JOIN
Correct Answer: a) INNER JOIN
Explanation: An INNER JOIN returns only the rows that have matching values in both the left and right tables. It excludes rows that do not have matches in either table.
Question 19
What is the primary function of a foreign key in a relational database?
a) To uniquely identify each row in a table
b) To refer to the primary key in another table
c) To store large amounts of data
d) To create indexes for faster queries
Correct Answer: b) To refer to the primary key in another table
Explanation: A foreign key in a relational database is used to create a link between two tables by referencing the primary key in another table.
Question 20
Which aggregate function in SQL calculates the total sum of values in a column?
a) AVG()
b) MIN()
c) SUM()
d) COUNT()
Correct Answer: c) SUM()
Explanation: The SUM() function adds together all the values in a specified column and returns the total.