wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Understanding DBMS Keys and Constraints

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is a primary key in a database?

a)

A primary key is a unique identifier for a record in a database.

b)

A primary key is used to store large text data.

c)

A primary key can be duplicated across records.

d)

A primary key is a type of foreign key.

2.

Define a foreign key and its purpose.

a)

A foreign key is a type of index that speeds up queries.

b)

A foreign key is used to delete records from a table.

c)

A foreign key is a unique identifier for a single table.

d)

A foreign key is a field that links two tables by referencing the primary key of another table, ensuring data integrity.

3.

What are the characteristics of a candidate key?

a)

A candidate key can be duplicated across rows.

b)

A candidate key must be unique, irreducible, and non-nullable.

c)

A candidate key must be a composite key.

d)

A candidate key can contain null values.

4.

Explain the concept of a composite key.

a)

A composite key is a single column that uniquely identifies a record.

b)

A composite key is a unique identifier made up of multiple columns in a database.

c)

A composite key is used to store images in a database.

d)

A composite key is a type of foreign key that links to another table.

5.

What is the difference between a primary key and a unique key?

a)

A primary key can be null and does not enforce uniqueness.

b)

A primary key cannot be null and uniquely identifies records, while a unique key can be null and also enforces uniqueness.

c)

A primary key can have duplicate values but must be unique across tables.

d)

A unique key can only be used in one table and cannot be referenced by foreign keys.

6.

What are domain constraints in a database?

a)

Domain constraints define the relationships between tables.

b)

Domain constraints are used to enforce referential integrity.

c)

Domain constraints determine the structure of the database schema.

d)

Domain constraints specify the valid values for attributes in a database.

7.

How do referential integrity constraints work?

a)

Referential integrity constraints maintain consistency between related tables by enforcing rules on foreign key relationships.

b)

They only apply to primary keys in a single table.

c)

They allow any data to be entered without restrictions.

d)

They are used to optimize database performance.

8.

What happens if a foreign key constraint is violated?

a)

The operation is rejected, maintaining referential integrity.

b)

The operation is completed successfully, ignoring the constraint.

c)

The database automatically deletes the related records.

d)

A warning is issued, but the operation proceeds anyway.

9.

Can a primary key be null? Why or why not?

a)

Yes, a primary key can be null.

b)

A primary key can be null if it is part of a composite key.

c)

A primary key can be null if it is defined as optional.

d)

No, a primary key cannot be null.

10.

What is the role of a surrogate key in a database?

a)

The role of a surrogate key in a database is to provide a unique identifier for records that is independent of the actual data.

b)

A surrogate key is used to store large amounts of data.

c)

A surrogate key is a foreign key that links tables together.

d)

A surrogate key is a type of index that speeds up queries.

11.

Describe the difference between entity integrity and referential integrity.

a)

Entity integrity focuses on unique and non-null primary keys, while referential integrity ensures valid foreign key relationships between tables.

b)

Entity integrity is concerned with data normalization, while referential integrity deals with data encryption.

c)

Entity integrity allows duplicate primary keys, whereas referential integrity does not allow null values.

d)

Entity integrity is about data types, while referential integrity is about indexing.

12.

What is a natural key? Provide an example.

a)

A natural key is a key that has a real-world meaning, such as a Social Security Number (SSN).

b)

A natural key is a key that has no relation to real-world entities, such as a primary key.

c)

A natural key is a key that is randomly generated, like a UUID.

d)

A natural key is a key that is only used internally within a database.

13.

How can domain constraints improve data quality?

a)

Domain constraints improve data quality by enforcing rules that prevent invalid data entries.

b)

They allow for more flexible data entry.

c)

They increase the amount of data stored.

d)

They automatically correct data errors.

14.

What is a self-referencing foreign key?

a)

A self-referencing foreign key is a foreign key that points to a different table.

b)

A self-referencing foreign key is a primary key that does not reference any table.

c)

A self-referencing foreign key is a foreign key that points to a view.

d)

A self-referencing foreign key is a foreign key that points to the same table.

15.

Explain the significance of normalization in relation to keys.

a)

Normalization increases data duplication and complexity.

b)

Normalization is only relevant for non-relational databases.

c)

Normalization is significant as it ensures that keys maintain data integrity and reduce redundancy.

d)

Normalization has no impact on the efficiency of keys.

16.

What is a check constraint? Give an example.

a)

CREATE TABLE Users (ID int, Age int NOT NULL);

b)

Example: CREATE TABLE Users (ID int, Age int CHECK (Age >= 18));

c)

CREATE TABLE Users (ID int, Age int UNIQUE);

d)

CREATE TABLE Users (ID int, Age int DEFAULT 0);

17.

How do you enforce referential constraints in SQL?

a)

Create indexes to enforce referential constraints.

b)

Use foreign keys to enforce referential constraints.

c)

Use triggers to enforce referential constraints.

d)

Use primary keys to enforce referential constraints.

18.

What is the purpose of a unique constraint?

a)

To allow duplicate values in a database column.

b)

To enforce uniqueness of values in a database column.

c)

To delete records from a database table.

d)

To create indexes for faster data retrieval.

19.

Can a table have multiple foreign keys?

a)

Yes, but only if the foreign keys reference the same table.

b)

Yes, a table can have multiple foreign keys.

c)

No, a table can only have one foreign key.

d)

No, foreign keys are not allowed in tables.

20.

What is the impact of cascading updates on referential constraints?

a)

Cascading updates only affect primary keys in the same table.

b)

Cascading updates require manual intervention to maintain referential integrity.

c)

Cascading updates delete child records when parent records are modified.

d)

Cascading updates maintain referential integrity by automatically updating foreign keys in child tables when primary keys in parent tables are changed.