Showing posts with label practice Quiz. Show all posts
Showing posts with label practice Quiz. Show all posts

Practice Quiz: Keys & Relationships in Databases

 

๐Ÿงช 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

  1. C

  2. B

  3. C

  4. B

  5. 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:

  1. Create a Students table with the following columns:

    • StudentID (Primary Key)

    • Name

    • Class

  2. Create a Marks table with the following columns:

    • MarkID (Primary Key)

    • StudentID (Foreign Key – linked to Students table)

    • Subject

    • Score

  3. 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.


Featured Post

CRUD Operations in SQL vs NoSQL Explained with Simple Examples

๐Ÿ”ท Part 6: CRUD Operations in SQL vs NoSQL – A Beginner's Guide This post will: ✅ Compare how to  Create ,  Read ,  Update , and  Del...

Popular Posts