Data Integrity and Constraints MCQs

What is data integrity in the context of databases?

A) Ensuring data is only accessible to authorized users
B) Ensuring data is accurate, consistent, and valid
C) Encrypting data during transmission
D) Controlling access to database objects
Answer: B
Which of the following is an example of maintaining data integrity?

A) Storing data in plain text format
B) Allowing unrestricted access to database tables
C) Using foreign key constraints to link tables
D) Using weak passwords for database authentication
Answer: C
What is referential integrity in a relational database?

A) Ensuring each column in a table has a unique value
B) Ensuring that foreign key values always refer to existing primary key values
C) Ensuring data is encrypted at rest
D) Controlling access to database objects based on roles
Answer: B
Which type of integrity constraint ensures that a column or set of columns have a unique value in each row?

A) Primary key constraint
B) Foreign key constraint
C) Check constraint
D) Default constraint
Answer: A
What is entity integrity in the context of database management?

A) Ensuring that each row in a table is unique
B) Ensuring that foreign key values refer to existing primary key values
C) Ensuring that each column in a table has a unique value
D) Ensuring that primary key values are automatically generated
Answer: D
Which constraint ensures that a column value must be unique across the entire table?

A) Primary key constraint
B) Unique constraint
C) Foreign key constraint
D) Check constraint
Answer: B
What does the NOT NULL constraint enforce?

A) Ensures that a column cannot have NULL values
B) Ensures that only one row is returned in a query
C) Ensures that data is stored in a specific format
D) Ensures that values are within a specified range
Answer: A
Which type of integrity constraint allows you to define a condition that must be true for each row in a table?

A) Primary key constraint
B) Foreign key constraint
C) Check constraint
D) Unique constraint
Answer: C
Which of the following is true about the PRIMARY KEY constraint?

A) It allows NULL values in the specified column
B) It uniquely identifies each row in a table
C) It enforces unique values across multiple tables
D) It is used to reference another table’s primary key
Answer: B
What is a foreign key constraint in a relational database?

A) It ensures that each row in a table is unique
B) It ensures that a column cannot have NULL values
C) It enforces referential integrity between tables
D) It defines a condition that must be true for each row in a table
Answer: C
Which of the following statements about CHECK constraints is true?

A) They enforce foreign key relationships between tables
B) They enforce unique values in a column
C) They define a condition that must be true for each row in a table
D) They ensure that a column cannot have NULL values
Answer: C
What is the purpose of a DEFAULT constraint in a database table?

A) To enforce referential integrity between tables
B) To ensure that a column cannot have NULL values
C) To define a condition that must be true for each row in a table
D) To provide a default value for a column if no value is specified
Answer: D
Which constraint is used to enforce domain integrity by restricting the type of data that can be stored in a column?

A) NOT NULL constraint
B) CHECK constraint
C) UNIQUE constraint
D) PRIMARY KEY constraint
Answer: B
What is domain integrity in database management?

A) Ensuring that each row in a table is unique
B) Ensuring that data is stored in a specific format or range of values
C) Ensuring that foreign key values refer to existing primary key values
D) Ensuring that only one row is returned in a query
Answer: B
Which of the following constraints ensures that each row in a table is uniquely identified?

A) PRIMARY KEY constraint
B) FOREIGN KEY constraint
C) CHECK constraint
D) UNIQUE constraint
Answer: A
What does the CASCADE option do when used with a foreign key constraint?

A) Updates the foreign key values automatically when a primary key value is updated
B) Deletes the foreign key rows automatically when a primary key row is deleted
C) Creates a new foreign key automatically when a primary key is added
D) Prevents the deletion of a primary key row if it has related foreign key rows
Answer: B
Which constraint is used to ensure that a column contains only numeric data?

A) NOT NULL constraint
B) CHECK constraint
C) UNIQUE constraint
D) PRIMARY KEY constraint
Answer: B
What is the purpose of a UNIQUE constraint in a database table?

A) To ensure that a column cannot have NULL values
B) To enforce referential integrity between tables
C) To define a condition that must be true for each row in a table
D) To enforce unique values in a column or set of columns
Answer: D
Which of the following is an example of an integrity constraint violation?

A) Inserting duplicate values into a column with a UNIQUE constraint
B) Using the CASCADE option with a foreign key constraint
C) Updating a primary key value in a table
D) Deleting rows from a table without using the WHERE clause
Answer: A
What does the PRIMARY KEY constraint enforce in a relational database table?

A) It ensures that a column cannot have NULL values
B) It ensures that each row is uniquely identified
C) It enforces referential integrity between tables
D) It defines a condition that must be true for each row in a table
Answer: B
Which of the following is an example of maintaining data integrity in a database?

A) Using weak passwords for database authentication
B) Storing data in plain text format
C) Enforcing foreign key relationships between tables
D) Allowing unrestricted access to database tables
Answer: C
What is the purpose of a foreign key constraint in a database?

A) To ensure that a column cannot have NULL values
B) To enforce referential integrity between tables
C) To define a condition that must be true for each row in a table
D) To enforce unique values in a column or set of columns
Answer: B
Which constraint ensures that a column cannot have NULL values?

A) PRIMARY KEY constraint
B) FOREIGN KEY constraint
C) CHECK constraint
D) NOT NULL constraint
Answer: D
What is the purpose of a CHECK constraint in a database table?

A) To enforce referential integrity between tables
B) To ensure that a column cannot have NULL values
C) To define a condition that must be true for each row in a table
D) To provide a default value for a column if no value is specified
Answer: C
Which of the following is true about a primary key constraint?

A) It can allow NULL values in the specified column
B) It uniquely identifies each row in a table
C) It enforces referential integrity between tables
D) It is used to reference another table’s primary key
Answer: B
What is a unique constraint in a database table?

A) It ensures that a column cannot have NULL values
B) It enforces referential integrity between tables
C) It ensures that each row is uniquely identified
D) It defines a condition that must be true for each row in a table
Answer: C
Which of the following is an example of maintaining data integrity in a database?

A) Using weak passwords for database authentication
B) Storing data in plain text format
C) Enforcing foreign key relationships between tables
D) Allowing unrestricted access to database tables
Answer: C
What is the purpose of a foreign key constraint in a database?

A) To ensure that a column cannot have NULL values
B) To enforce referential integrity between tables
C) To define a condition that must be true for each row in a table
D) To enforce unique values in a column or set of columns
Answer: B
Which constraint ensures that a column cannot have NULL values?

A) PRIMARY KEY constraint
B) FOREIGN KEY constraint
C) CHECK constraint
D) NOT NULL constraint
Answer: D
What is the purpose of a CHECK constraint in a database table?

A) To enforce referential integrity between tables
B) To ensure that a column cannot have NULL values
C) To define a condition that must be true for each row in a table
D) To provide a default value for a column if no value is specified
Answer: C
Which of the following is true about a primary key constraint?

A) It can allow NULL values in the specified column
B) It uniquely identifies each row in a table
C) It enforces referential integrity between tables
D) It is used to reference another table’s primary key
Answer: B
What is a unique constraint in a database table?

A) It ensures that a column cannot have NULL values
B) It enforces referential integrity between tables
C) It ensures that each row is uniquely identified
D) It defines a condition that must be true for each row in a table
Answer: C
Which of the following is an example of maintaining data integrity in a database?

A) Using weak passwords for database authentication
B) Storing data in plain text format
C) Enforcing foreign key relationships between tables
D) Allowing unrestricted access to database tables
Answer: C
What is the purpose of a foreign key constraint in a database?

A) To ensure that a column cannot have NULL values
B) To enforce referential integrity between tables
C) To define a condition that must be true for each row in a table
D) To enforce unique values in a column or set of columns
Answer: B
Which constraint ensures that a column cannot have NULL values?

A) PRIMARY KEY constraint
B) FOREIGN KEY constraint
C) CHECK constraint
D) NOT NULL constraint
Answer: D
What is the purpose of a CHECK constraint in a database table?

A) To enforce referential integrity between tables
B) To ensure that a column cannot have NULL values
C) To define a condition that must be true for each row in a table
D) To provide a default value for a column if no value is specified
Answer: C
Which of the following is true about a primary key constraint?

A) It can allow NULL values in the specified column
B) It uniquely identifies each row in a table
C) It enforces referential integrity between tables
D) It is used to reference another table’s primary key
Answer: B
What is a unique constraint in a database table?

A) It ensures that a column cannot have NULL values
B) It enforces referential integrity between tables
C) It ensures that each row is uniquely identified
D) It defines a condition that must be true for each row in a table
Answer: C
Which of the following is an example of maintaining data integrity in a database?

A) Using weak passwords for database authentication
B) Storing data in plain text format
C) Enforcing foreign key relationships between tables
D) Allowing unrestricted access to database tables
Answer: C
What is the purpose of a foreign key constraint in a database?

A) To ensure that a column cannot have NULL values
B) To enforce referential integrity between tables
C) To define a condition that must be true for each row in a table
D) To enforce unique values in a column or set of columns
Answer: B
Which constraint ensures that a column cannot have NULL values?

A) PRIMARY KEY constraint
B) FOREIGN KEY constraint
C) CHECK constraint
D) NOT NULL constraint
Answer: D
What is the purpose of a CHECK constraint in a database table?

A) To enforce referential integrity between tables
B) To ensure that a column cannot have NULL values
C) To define a condition that must be true for each row in a table
D) To provide a default value for a column if no value is specified
Answer: C
Which of the following is true about a primary key constraint?

A) It can allow NULL values in the specified column
B) It uniquely identifies each row in a table
C) It enforces referential integrity between tables
D) It is used to reference another table’s primary key
Answer: B
What is a unique constraint in a database table?

A) It ensures that a column cannot have NULL values
B) It enforces referential integrity between tables
C) It ensures that each row is uniquely identified
D) It defines a condition that must be true for each row in a table
Answer: C
Which of the following is an example of maintaining data integrity in a database?

A) Using weak passwords for database authentication
B) Storing data in plain text format
C) Enforcing foreign key relationships between tables
D) Allowing unrestricted access to database tables
Answer: C
What is the purpose of a foreign key constraint in a database?

A) To ensure that a column cannot have NULL values
B) To enforce referential integrity between tables
C) To define a condition that must be true for each row in a table
D) To enforce unique values in a column or set of columns
Answer: B
Which constraint ensures that a column cannot have NULL values?

A) PRIMARY KEY constraint
B) FOREIGN KEY constraint
C) CHECK constraint
D) NOT NULL constraint
Answer: D
What is the purpose of a CHECK constraint in a database table?

A) To enforce referential integrity between tables
B) To ensure that a column cannot have NULL values
C) To define a condition that must be true for each row in a table
D) To provide a default value for a column if no value is specified
Answer: C
Which of the following is true about a primary key constraint?

A) It can allow NULL values in the specified column
B) It uniquely identifies each row in a table
C) It enforces referential integrity between tables
D) It is used to reference another table’s primary key
Answer: B
What is a unique constraint in a database table?

A) It ensures that a column cannot have NULL values
B) It enforces referential integrity between tables
C) It ensures that each row is uniquely identified
D) It defines a condition that must be true for each row in a table
Answer: C

All Copyrights Reserved 2025 Reserved by T4Tutorials