Skip to content
← All labs
Databases / Hands-on lab

Model event registrations in DynamoDB

Use partition and sort keys to retrieve registrations for one event without scanning the whole table.

Beginner40 minutesUpdated 2026-09-23Use your own AWS learning account

Overview

A campus event team needs to retrieve everyone registered for a particular event. Model that access pattern first, then create and query a small DynamoDB table with synthetic records.

Architecture

An authorized console session writes items to a DynamoDB table. eventId groups registrations; studentId uniquely identifies a registration within an event. A Query reads a selected partition. This lab has no public API or frontend.

KeyTypePurpose
eventIdString, partition keyGroup registrations by event
studentIdString, sort keyIdentify one registration

DynamoDB suits known key-based access patterns. If your application needs relational joins and flexible transactions across related entities, evaluate a relational database instead.

Prerequisites

  • A learning account with permission to create, read, write, and delete a DynamoDB table.
  • One selected AWS region and a unique project table name.
  • Use synthetic student IDs only.

Steps

1. Create the table

Create cloudadhar-event-registrations with string partition key eventId and string sort key studentId. Choose on-demand capacity in the table settings. Do not add secondary indexes or optional streams for this exercise. Wait for the table to become Active.

2. Add a sample registration

In Explore items, create an item using the JSON editor in DynamoDB JSON mode:

json
{
  "eventId": {"S": "cloud-day"},
  "studentId": {"S": "student-001"},
  "status": {"S": "registered"}
}

Create two more items: cloud-day / student-002 and career-day / student-003. Give each the same status attribute.

3. Query one event

Select Query rather than Scan. Enter cloud-day as the partition-key value and run the query without a sort-key filter. Expect two records. Enable strongly consistent reads if the console offers the option, or retry briefly after writes.

4. Narrow the result

Keep the same partition key and add an equality condition on sort key student-002. Expect exactly one item. Change that item's status to attended, rerun the query, and confirm the update.

5. Test another access pattern

Try explaining how to list every event attended by one student with the current key design. You cannot efficiently query that directly by this partition key. Sketch a possible secondary index, but do not create it in this lab. Describe the extra cost and write overhead.

Verification

  • Querying cloud-day returns exactly two registrations.
  • Adding sort key student-002 returns one registration with status attended.
  • career-day is not present in the cloud-day results.
  • You can explain why a Scan is a different operation from a key-based Query.

Cost and cleanup

On-demand does not mean free: requests, stored data, and optional features can incur charges. Delete only cloudadhar-event-registrations after saving redacted evidence. Check for backups if you explicitly created any, and verify that the table no longer appears in the region.

References