A university portal stores students, courses and enrollments in one DynamoDB table. The app must list all courses for a student and all students in a course, with each query served by key lookups rather than scans. Which data model should the team use?
Show answer and explanation
Answer: B
An adjacency-list design stores entities and their links as items in one table. Each enrollment item uses the student as partition key and the course as sort key, and a global secondary index with the keys swapped serves the course-to-student direction. Both access patterns become key-based queries, which scale without scans and keep data duplication low.
Why the other options are wrong
- A. Keeping every course inside one student item makes the course-side query a scan across all students. The item also grows with each enrollment and can reach the 400 KB item size limit.
- C. DynamoDB has no joins, so separate tables combined in application code force reads across whole tables. This pattern is slow and expensive at scale.
- D. Athena can query exported data, but it is an analytics service with per-query latency and scan cost. It is not the right serving layer for an application that needs low-latency key lookups.