Relational Data Model and Constraints MCQs Flashcards
(30 cards)
Which of the following is NOT a characteristic of a relation in the relational data model?
o A) Each relation has a unique name.
o B) Each relation can have duplicate rows.
o C) Each relation consists of tuples.
o D) Each tuple has a fixed number of attributes.
Each relation can have duplicate rows.
What is a primary key in a relational database?
o A) A key that allows duplicate values
o B) A unique identifier for a record in a table
o C) A foreign key referencing another table
o D) An attribute that can be null
A unique identifier for a record in a table
What does the NOT NULL constraint enforce in a relational database?
o A) A column cannot contain duplicate values
o B) A column must have a value (cannot be empty)
o C) A column can only have unique values
o D) A column must have a default value
A column must have a value (cannot be empty)
Which of the following describes a composite primary key?
o A) A primary key made of a single attribute
o B) A primary key that is automatically generated
o C) A primary key consisting of multiple attributes
o D) A primary key that allows null values
A primary key consisting of multiple attributes
Which of the following constraints can be used to enforce business rules in a relational database?
o A) Primary key constraint
o B) Foreign key constraint
o C) Check constraint
o D) All of the above
All of the above
What is the role of a foreign key in a relational database?
o A) To uniquely identify a record
o B) To reference a primary key in another table
o C) To enforce referential integrity
o D) Both B and C
Both B and C
Which SQL command can be used to add constraints to an existing table?
o A) CREATE
o B) ALTER
o C) UPDATE
o D) INSERT
ALTER
What does the CHECK constraint do in a relational database?
o A) Ensures a column has a unique value
o B) Ensures a column cannot be null
o C) Enforces a specific condition on a column’s values
o D) Links two tables together
Enforces a specific condition on a column’s values
What is the effect of a cascading delete in a relational database?
o A) It prevents deletion of records
o B) It deletes a record and all related records in other tables
o C) It only deletes the primary key
o D) It creates a backup of the deleted records
It deletes a record and all related records in other tables
What does the term “referential integrity” specifically refer to?
o A) Maintaining a unique primary key in each table
o B) Ensuring that foreign keys correctly reference existing primary keys
o C) Enforcing that no attribute can be null
o D) Restricting updates to primary keys
Ensuring that foreign keys correctly reference existing primary keys
In a relational database, how can you define a default value for a column?
o A) By using the DEFAULT constraint
o B) By using the NOT NULL constraint
o C) By using the CHECK constraint
o D) By specifying it in the CREATE TABLE statement
By using the DEFAULT constraint
Which SQL statement is used to remove a constraint from a table?
o A) DROP
o B) DELETE
o C) REMOVE
o D) ALTER
ALTER
What does the term “cascade” mean in the context of referential integrity?
o A) It allows changes in one table to affect another table.
o B) It prevents any changes to the primary key.
o C) It enforces uniqueness across multiple tables.
o D) It allows for duplicate records in a table.
It allows changes in one table to affect another table.
What is the difference between a primary key and a unique key?
o A) A primary key can be null; a unique key cannot.
o B) A unique key can have multiple null values; a primary key cannot.
o C) Both serve the same purpose.
o D) A primary key is used for foreign key relationships; a unique key is not.
A unique key can have multiple null values; a primary key cannot.
In relational databases, what is the role of the database schema?
o A) It defines how data is stored in physical files.
o B) It describes the structure of the database, including tables and relationships.
o C) It enforces data integrity rules.
o D) It represents the data in a graphical format.
It describes the structure of the database, including tables and relationships.
Which of the following constraints is automatically enforced by the database system?
o A) CHECK
o B) NOT NULL
o C) UNIQUE
o D) Both B and C
Both B and C
What is the outcome of trying to remove a primary key that is referenced by a foreign key in another table?
o A) The primary key is removed, and the foreign key is set to null.
o B) The primary key is removed, and the foreign key is also removed.
o C) An error occurs due to referential integrity violation.
o D) The operation is successful without any restrictions.
An error occurs due to referential integrity violation.
Which of the following operations might violate referential integrity?
o A) Inserting a record with a valid foreign key
o B) Deleting a record that is referenced by a foreign key
o C) Updating a primary key that is not referenced
o D) None of the above
Deleting a record that is referenced by a foreign key
What does the term “entity integrity” ensure in a relational database?
o A) All foreign keys must match primary keys.
o B) No two entities can have the same primary key value.
o C) All attributes must have values.
o D) All relationships must be defined.
No two entities can have the same primary key value.
In SQL, which statement is used to create a new table with constraints?
o A) CREATE TABLE
o B) NEW TABLE
o C) INSERT TABLE
o D) DEFINE TABLE
CREATE TABLE
What type of relationship is represented by a one-to-many constraint in a relational database?
o A) A single entity can relate to multiple entities.
o B) Multiple entities can relate to a single entity.
o C) Entities cannot relate to each other.
o D) Both A and B
Both A and B
What is the purpose of normalization in the context of relational databases?
o A) To optimize query performance
o B) To eliminate redundancy and ensure data integrity
o C) To create backup copies of the database
o D) To enforce constraints on attributes
To eliminate redundancy and ensure data integrity
What does it mean when a foreign key is said to have “cascading updates”?
o A) Changes to the primary key are automatically reflected in the foreign key.
o B) All foreign keys in the database are updated.
o C) The foreign key can only be updated manually.
o D) None of the above
Changes to the primary key are automatically reflected in the foreign key.
Which of the following constraints can be used to enforce a business rule, such as “age must be greater than 18”?
o A) PRIMARY KEY
o B) UNIQUE
o C) CHECK
o D) FOREIGN KEY
CHECK