Year1- SQL Practice Worksheet
📚 School Database Schema (Tables)
Below are the tables for the school database schema. Each table contains fields that
define its structure.
Students
Field Data Type Constraints
student_id INT PRIMARY KEY
first_name VARCHAR(50)
last_name VARCHAR(50)
date_of_birth DATE
gender CHAR(1)
grade_level INT
Teachers
Field Data Type Constraints
teacher_id INT PRIMARY KEY
first_name VARCHAR(50)
last_name VARCHAR(50)
subject VARCHAR(100)
Courses
Field Data Type Constraints
course_id INT PRIMARY KEY
course_name VARCHAR(100)
teacher_id INT FOREIGN KEY
REFERENCES
Teachers(teacher_id)
Enrollments
Field Data Type Constraints
enrollment_id INT PRIMARY KEY
student_id INT FOREIGN KEY
REFERENCES
Students(student_id)
course_id INT FOREIGN KEY
REFERENCES
Courses(course_id)
enrollment_date DATE
Grades
Field Data Type Constraints
grade_id INT PRIMARY KEY
enrollment_id INT FOREIGN KEY
REFERENCES
Enrollments(enrollment_id)
grade CHAR(2)
🧠 SQL Practice Questions
1. Retrieve all student names and their grade levels.
2. Show all courses taught by a specific teacher.
3. List students born after the year 2008.
4. List student names along with the courses they are enrolled in.
5. Find all students and their grades for each course.
6. Show all courses along with the teacher names.
7. Find the total number of students in Grade 11.
8. Count how many students are enrolled in each course.
9. List the names of students who have enrolled in more than 2 courses.
To create the student table:
CREATE TABLE Students (
student_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
date_of_birth DATE,
gender CHAR(1),
grade_level INT
);
*Create all the tables in the database using SQL commands.