๐งช Practice Quiz: Keys & Relationships in Databases
Level: Beginner
Purpose: Reinforce concepts from Part 4
Format: 5 multiple choice questions + answers at the end
๐ธ Quiz Questions
1. What is the primary purpose of a Primary Key in a database table?
A. To store large files
B. To create duplicate records
C. To uniquely identify each record
D. To format column headers
2. Which of the following can be a valid Primary Key?
A. A student’s name
B. A unique ID number like StudentID
C. A subject name
D. A course title
3. What is a Foreign Key used for?
A. To store passwords securely
B. To make a copy of the table
C. To connect two tables by referencing a Primary Key
D. To delete data from another table
4. In a relationship between Students and Results, which table usually contains the Foreign Key?
A. Students
B. Results
C. Teachers
D. Courses
5. True or False: A Foreign Key must always refer to a column that is a Primary Key in another table.
✅ Answers
-
C
-
B
-
C
-
B
-
True
๐ Mini Assignment: Create Your Own Tables and Define Keys
Objective: Apply what you've learned by designing two simple tables with a relationship.
๐ Instructions:
-
Create a Students table with the following columns:
-
StudentID
(Primary Key) -
Name
-
Class
-
-
Create a Marks table with the following columns:
-
MarkID
(Primary Key) -
StudentID
(Foreign Key – linked to Students table) -
Subject
-
Score
-
-
Write the SQL commands to create both tables and define the keys.
๐ก Optional Challenge:
Insert sample data into both tables (at least 2 students and 3 marks) and write a query to display student names along with their subjects and scores.
Find solution to the assignment in next post.