wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Database Constraints Quiz

Total questions: 40

Worksheet time: 3600secs

Name
Class
Date
1.

You are designing a Product table for an inventory system. Each product must have a unique serial number, and the price must always be greater than zero. What combination of constraints would you apply?

a)

Primary Key on serial_number, Not Null on price

b)

Unique on serial_number, Check constraint on price

c)

Primary Key on serial_number, Check constraint on price > 0

d)

Unique on serial_number, Not Null on price

2.

Which constraint would ensure that no two rows in the same table have the same values in a specific column?

a)

Not Null Constraint

b)

Primary Key Constraint

c)

Foreign Key Constraint

d)

Unique Constraint

3.

table Order with a column Customer ID references Customer table with the primary key Customer ID. What constraint would you use to enforce this relationship?

a)

Primary Key Constraint

b)

Check Constraint

c)

Foreign Key Constraint

d)

Unique Constraint

4.

In which situation would you use an ON DELETE CASCADE referential constraint?

a)

When you want to delete all orders if the related customer is deleted

b)

When you want to prevent deleting a customer if they have existing orders

c)

When you want to update all foreign keys when a primary key is modified

d)

When you want to set the foreign key to null if the parent record is deleted

5.

A Not Null constraint is used to:

a)

Ensure no duplicates exist in a column

b)

Ensure a column has a value and does not contain nulls

c)

Ensure referential integrity between two tables

d)

Ensure a column has unique values

6.

You are tasked with creating a Customer table where the email address must be unique for each customer. What constraint would you apply to the email column?

a)

Not Null Constraint

b)

Foreign Key Constraint

c)

Check Constraint

d)

Unique Constraint

7.

Each department can have multiple employees, but each employee can belong to only one department. What kind of relationship does this represent?

a)

One-to-One

b)

One-to-Many

c)

Many-to-Many

d)

Self-referencing

8.

Which integrity constraint would you use to ensure that a salary column in an Employee table only accepts values greater than zero?

a)

Foreign Key Constraint

b)

Unique Constraint

c)

Check Constraint

d)

Primary Key Constraint

9.

In a library database, each book can only be checked out by one member at a time, but a member can check out multiple books. What type of relationship should you define between Member and Book tables?

a)

One-to-One

b)

One-to-Many

c)

Many-to-Many

d)

Self-referencing

10.

Which of the following is not a characteristic of a Primary Key?

a)

Must be unique

b)

Must be indexed

c)

Can contain null values

d)

Can be an integer or a string

11.

You are designing a schema where an employee can be managed by another employee, and you need to model this relationship within the same table. How would you represent this?

a)

Use a self-referencing foreign key in the Employee table

b)

Create a One-to-One relationship between two different tables

c)

Create a Many-to-Many relationship between two different tables

d)

Store the manager information in a separate table

12.

A Foreign Key constraint ensures that:

a)

All values in a column are unique

b)

All values in a column must refer to a valid value in another table

c)

A column cannot contain null values

d)

A column must meet certain conditions

13.

Which of the following is a valid reason to use a Check Constraint?

a)

To ensure that an email field contains a valid domain

b)

To enforce unique values in a column

c)

To prevent null values in a column

d)

To ensure referential integrity between two tables

14.

Suppose that there are two tables, Customer and Order. If a customer is deleted, all related orders should also be deleted. What referential action should you use?

a)

ON DELETE CASCADE

b)

ON DELETE SET NULL

c)

ON DELETE RESTRICT

d)

ON DELETE NO ACTION

15.

In which situation would you use an ON DELETE SET NULL referential constraint?

a)

When you want to delete child records when the parent record is deleted

b)

When you want to prevent deleting parent records if there are child records

c)

When you want to set the foreign key to null if the parent record is deleted

d)

When you want to update the foreign key when the primary key is updated

16.

A Customer table has a foreign key referencing the Country table, but you want to ensure that if a country is deleted, the related customer records should remain, with the Country ID set to null. How would you enforce this?

a)

ON DELETE RESTRICT

b)

ON DELETE CASCADE

c)

ON DELETE SET NULL

d)

ON DELETE NO ACTION

17.

You are designing a hotel booking system where each room can only be booked by one customer at a time, but each customer can book multiple rooms during their stay. What type of relationship should you create between the Room and Customer tables?

a)

One-to-One

b)

One-to-Many

c)

Many-to-Many

d)

One-to-One with a Junction table

18.

Which type of constraint would you apply to a column that should not contain duplicate values but can contain nulls?

a)

Primary Key Constraint

b)

Foreign Key Constraint

c)

Check Constraint

d)

Unique Constraint

19.

In a sales database, you want to ensure that discounts are never negative. What constraint should you apply to the Discount column?

a)

Foreign Key Constraint

b)

Check Constraint

c)

Primary Key Constraint

d)

Not Null Constraint

20.

What is the main purpose of a Foreign Key Constraint in a relational database?

a)

To ensure that data is unique across rows

b)

To prevent null values from being entered

c)

To enforce referential integrity between tables

d)

To ensure that values follow specific conditions

21.

You have a Product table where each product can have multiple suppliers, and the supplier information is repeated for each product. What normal form is this table violating?

a)

First Normal Form (1NF)

b)

Second Normal Form (2NF)

c)

Third Normal Form (3NF)

d)

Fourth Normal Form (4NF)

22.

Which of the following ensures that all data is atomic and eliminates repeating groups?

a)

First Normal Form (1NF)

b)

Second Normal Form (2NF)

c)

Third Normal Form (3NF)

d)

Boyce-Codd Normal Form (BCNF)

23.

You have an Orders table where both Order ID and Product ID form the composite primary key. The Customer Name is also stored in this table but only depends on Order ID. What normal form does this table violate?

a)

1NF

b)

2NF

c)

3NF

d)

BCNF

24.

table is in Second Normal Form (2NF) when:

a)

It has no repeating groups

b)

Every non-key attribute is fully dependent on the entire primary key

c)

There are no transitive dependencies

d)

Every functional dependency is a superkey

25.

You are working with a university database where students can enroll in multiple courses, and each course is taught by a single instructor. How would you design this to meet 3NF?

a)

Combine students, courses, and instructors into one table

b)

Use composite keys without normalization

c)

Create separate tables for students, courses, instructors, and a junction table for enrollments

d)

Store instructor details with student data

26.

Which normal form removes transitive dependencies, ensuring that non-key attributes do not depend on other non-key attributes?

a)

First Normal Form (1NF)

b)

Second Normal Form (2NF)

c)

Third Normal Form (3NF)

d)

Fourth Normal Form (4NF)

27.

The following table stores customer orders, where Order ID and Customer Name are included. Customer Name only depends on Order ID, not on Product details. What normal form is violated?

a)

1NF

b)

2NF

c)

3NF

d)

BCNF

28.

In which normal form must a table be if it is already in BCNF?

a)

1NF

b)

2NF

c)

All of the above

d)

3NF

29.

In a Books table, you store Author Name, Book Title, and Publisher Name. The Publisher Name depends on the Author Name but not the Book Title. How would you bring this table to 3NF?

a)

Leave it as is

b)

Move Publisher Name to a separate table

c)

Create a composite primary key

d)

Normalize it to BCNF

30.

Which of the following best describes Boyce-Codd Normal Form (BCNF)?

a)

A stricter form of 2NF

b)

A stricter form of 3NF

c)

Focuses on eliminating partial dependencies

d)

Only deals with multivalued dependencies

31.

You are designing a database for a retail store. Each product can be supplied by multiple vendors, and each vendor can supply multiple products. How would you design this to eliminate redundancy?

a)

Combine both products and vendors into a single table for simplicity.

b)

Create separate tables for products, vendors, and a junction table for product-vendor relationships.

c)

Denormalize the data by merging products and vendors into one table for easier access.

d)

Use composite keys to link both products and vendors in a single relationship.

32.

The following table stores student information where Student ID is the primary key, and a student can have multiple hobbies and enroll in multiple courses. What normal form is violated?

a)

1NF

b)

2NF

c)

4NF

d)

BCNF

33.

A table is in 4NF if:

a)

It is in BCNF and there are no multivalued dependencies

b)

It is in 3NF and there are no transitive dependencies

c)

It is in 2NF and there are no partial dependencies

d)

It has a composite primary key

34.

In a hospital database, each doctor can have multiple patients, and each patient can be treated by multiple doctors. How would you normalize this relationship?

a)

Create a many-to-many relationship by using a junction table between doctors and patients.

b)

Store all the data in a single table, utilizing composite keys to link the records.

c)

Denormalize the data into one large table to improve query performance.

d)

Use multiple foreign keys to link the tables but without any normalization.

35.

Which normal form deals specifically with eliminating partial dependencies in composite keys?

a)

1NF

b)

2NF

c)

3NF

d)

4NF

36.

You are creating a Students table where each student can enroll in multiple courses, but each course has only one instructor. If the table also has an Instructor ID for each course, what normal form is it violating?

a)

1NF

b)

2NF

c)

3NF

d)

BCNF

37.

In which normal form are multivalued dependencies eliminated?

a)

1NF

b)

2NF

c)

3NF

d)

4NF

38.

The following table stores courses and instructors, but each course has only one Instructor. If the course time is dependent on the Instructor, not the course itself, what normal form is violated?

a)

1NF

b)

2NF

c)

3NF

d)

BCNF

39.

Why might you choose to denormalize a database?

a)

To increase redundancy

b)

To improve query performance

c)

To reduce data anomalies

d)

To enforce stronger data integrity

40.

In a sales database, orders include both customer and product information. You need to avoid anomalies while maintaining performance. What strategy would you use?

a)

Fully normalize the data to 3NF and use joins for all queries

b)

Denormalize the data by combining customer and order information into one table

c)

Normalize the data but introduce indexing for performance

d)

Store everything in one table for simplicity