Exam table: one for the highest score (desc_rk) and one for the lowest score (asc_rk) using the RANK() window function partitioned by exam_id.Student table on student_id to get student names.student_id and student_name.HAVING clause to filter out students who have a minimum rank of 1 in either desc_rk or asc_rk, which indicates they have scored the highest or lowest in at least one exam.student_id.
erDiagram
Student {
int student_id PK
varchar student_name
}
Exam {
int exam_id PK
int student_id PK
int score
}
Student ||--o{ Exam : has