You work for a university's academic records system. The school has students enrolled in various subjects, and students take examinations throughout the semester.
Given three database tables:
- Students: Contains student information (ID and name)
- Subjects: Contains all available subjects in the school
- Examinations: Records every time a student takes an exam (may contain duplicates since students can retake exams)
Your task is to create a comprehensive report showing how many times each student attended each exam, including subjects where a student attended zero exams.
The result should be ordered by student_id and subject_name.
Example: If Alice is enrolled and there are subjects Math and Physics, but she only took 2 Math exams and 0 Physics exams, your report should show both entries with counts 2 and 0 respectively.
Input & Output
Visualization
Time & Space Complexity
Reading tables plus sorting final result - database engines optimize joins efficiently
Final result contains all student-subject combinations
Constraints
- 1 โค students.length โค 1000
- 1 โค subjects.length โค 100
- 0 โค examinations.length โค 104
- 1 โค student_id โค 1000
- 1 โค student_name.length, subject_name.length โค 20
- Each student_id in examinations exists in students table
- Each subject_name in examinations exists in subjects table