wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Understanding Primary Keys in Databases

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is a primary key in a database?

a)

A primary key is an optional field in a database.

b)

A primary key is a type of foreign key.

c)

A primary key can be duplicated across records.

d)

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

2.

Why is a primary key important for a database?

a)

A primary key is only necessary for relational databases, not for others.

b)

A primary key can be duplicated across records to allow for flexibility.

c)

A primary key is important because it ensures each record is unique and maintains data integrity.

d)

A primary key is used to store large amounts of data efficiently.

3.

Can a primary key contain NULL values?

a)

A primary key can contain multiple NULL values.

b)

Yes, a primary key can contain NULL values.

c)

No, a primary key cannot contain NULL values.

d)

A primary key can have one NULL value.

4.

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

a)

A primary key can be null; a foreign key cannot be null.

b)

A primary key is used for indexing; a foreign key is for data validation.

c)

A primary key uniquely identifies records; a foreign key links records between tables.

d)

A primary key is always a string; a foreign key is always an integer.

5.

How many primary keys can a table have?

a)

3

b)

Unlimited

c)

1

d)

2

6.

What happens if you try to insert a duplicate primary key?

a)

The duplicate key will be automatically updated.

b)

The database will ignore the duplicate key and proceed.

c)

The insertion will succeed without any issues.

d)

The insertion will fail with an error.

7.

Which data types are commonly used for primary keys?

a)

Float

b)

Boolean

c)

Integer, String (UUID), Composite Key

d)

DateTime

8.

Can a composite key be used as a primary key?

a)

A composite key is only used for foreign keys.

b)

No, a composite key cannot be used as a primary key.

c)

Yes, a composite key can be used as a primary key.

d)

Composite keys are not allowed in any database.

9.

What is the role of a primary key in ensuring data integrity?

a)

The primary key ensures data integrity by uniquely identifying records and preventing duplicates.

b)

The primary key is used to encrypt sensitive data in the database.

c)

The primary key allows multiple records to have the same identifier.

d)

The primary key serves as a foreign key in other tables.

10.

How do you define a primary key in SQL?

a)

A primary key is automatically created for every table in SQL.

b)

A primary key can be any column in a table without restrictions.

c)

A primary key is defined using the PRIMARY KEY constraint in SQL.

d)

A primary key is defined using the UNIQUE constraint in SQL.