Unit 4: Keys and Relationships

1. What is a Key?

A key is a field used to identify records in a table or to establish a connection between tables. For example: Primary Key and Foreign Key.

2. Why are keys important?

Keys are important because they help us:

3. What is a Primary Key?

A Primary Key is a field that uniquely identifies each record in a table.

Example: Consider the following Students table:

Student_ID Student_Name Class
101 Rahul 10
102 Priya 10
103 Aman 10

Here, Student_ID can be used as the Primary Key because every student has a different ID.

4. Why is a Primary Key Required?

A Primary Key is required to identify each record uniquely.

Example: Suppose two students have the same name:

Student_ID Name
101 Rahul
102 Rahul

The Name field cannot uniquely identify the students. But: Rahul → Student_ID 101 Rahul → Student_ID 102

Therefore, Student_ID is set as the Primary Key.

5. What are the Characteristics of a Primary Key?

6. What is a Null value?

A Null value indicates that a field has no value stored (nothing has been entered).

It is not Zero (0). It is not Blank (“ ”).

7. How to Set a Primary Key in MS Access?

8. Why is the AutoNumber data type often used for a Primary Key?

The AutoNumber data type is often used for a Primary Key because Access automatically generates a unique number for each new record.

9. What is a Foreign Key?

A Foreign Key is a field in one table that is linked to the Primary Key of another table. It is used to establish a relationship between tables.

Example of Foreign Key: Suppose we have two tables.

Student_ID Student_Name Class
101 Rahul 10
102 Priya 10
103 Aman 10

Here: Student_ID → Primary Key

Fee_ID Student_ID Amount
1 101 ₹2500
2 102 ₹2500
3 103 ₹2500

Here: Fee_ID → Primary Key Student_ID → Foreign Key

The Student_ID in the Fees table connects to Student_ID in the Students table. Students.Student_ID → Fees.Student_ID

10. Distinguish between Primary Key and Foreign Key

Primary Key Foreign Key
Identifies Connects
Uniquely identifies a record in its table. Links one table to another table.
Contains unique values. May contain repeated values.
Cannot contain Null values. May contain Null values.
There is only one Primary Key per table. A table can have one or more Foreign Keys.

11. What is Referential Integrity?

Referential Integrity ensures that relationships between related tables remain valid and consistent.

12. What is a Relationship?

A relationship is a connection between tables through related fields (Foreign Keys).

13. Why do we need Relationships?

We need relationships to connect to the information stored in separate tables. A Foreign Key connects two tables.

14. What are the types of Relationships in a database?

15. What is One-to-One Relationship?

In a One-to-One relationship, one record in one table is related to only one record in another table.

Database Table

16. What is One-to-Many Relationship?

In a One-to-Many relationship, one record in one table can be related to many records in another table.

Database Table

17. What is Many-to-Many Relationship?

In a Many-to-Many relationship, many records in one table can be related to many records in another table.

Database Table