Skip to content
← All patterns

library

Library Management

Which loans are overdue?

Track branches, members, book copies and loans, and find what's overdue.

Branches, patrons, books, the copies each branch holds and every checkout share one table. A patron's checkouts sit in their own partition, so one query returns everything they have on loan, and an index sorts those checkouts by due date to find overdue ones. A separate card item and a conditional write keep library card numbers unique.

The model

PatronCard

Uniqueness tracker for library card numbers - enables conditional writes

pk
CARD#<cardNumber>
sk
CARD#<cardNumber>

Attributes: PK (S), SK (S), cardNumber (S), patronId (S), issuedAt (S)

Branch

A physical library branch location with address and contact information

pk
BRANCH#<branchId>
sk
BRANCH#<branchId>

Attributes: PK (S), SK (S), branchId (S), name (S), address (S), city (S), phone (S), openingHours (M), createdAt (S)

Patron

A library member who can borrow books from any branch

pk
BRANCH#<branchId>
sk
PATRON#<patronId>

Attributes: PK (S), SK (S), GSI1PK (S), patronId (S), cardNumber (S), firstName (S), lastName (S), email (S), membershipTier (S), maxCheckouts (N), createdAt (S)

Checkout

Record of a borrowed book with due date tracking

pk
PATRON#<patronId>
sk
CHECKOUT#<checkoutId>

Attributes: PK (S), SK (S), GSI1PK (S), GSI1SK (S), checkoutId (S), patronId (S), copyId (S), isbn (S), title (S), checkoutDate (S), dueDate (S), returnedDate (S), renewalCount (N)

Book

A book in the catalogue identified by ISBN

pk
BOOK#<isbn>
sk
BOOK#<isbn>

Attributes: PK (S), SK (S), isbn (S), title (S), author (S), publisher (S), publishYear (N), genre (S), description (S), pageCount (N)

BookCopy

A physical copy of a book at a specific branch

pk
BRANCH#<branchId>
sk
COPY#<copyId>

Attributes: PK (S), SK (S), GSI2PK (S), GSI2SK (S), copyId (S), isbn (S), branchId (S), condition (S), status (S), acquiredDate (S)

Access patterns

  • QueryGet all patrons for a branch

    List all library members registered at a specific branch

  • QueryGet patron's active checkouts

    List all books currently checked out by a patron

  • Query · GSI1Find overdue items

    Query GSI1 with date condition to find all overdue checkouts

  • Query · GSI2Check book availability across all branches

    Find which branches have available copies of a book

  • GetItemValidate card uniqueness

    Check if a library card number is already in use

  • QueryGet branch inventory

    List all book copies at a specific branch

  • QueryGet branch details

    Fetch one branch's address, phone and opening hours.

  • QueryGet book details by ISBN

    Fetch a book's catalogue entry by its ISBN.

Design notes

PatronCard as separate itemtrade-off

Enables library card number uniqueness check via conditional write (attribute_not_exists) without requiring a GSI scan. Adds one extra item per patron but eliminates the need for a GSI just for uniqueness.

Checkouts under Patron PKwhy

Storing checkouts with PK=PATRON#<patronId> enables "get patron with all checkouts" in a single query using begins_with on the sort key. The alternative (checkouts under Branch) would require a GSI for this common access pattern.

BookCopy separate from Bookwhy

Physical copies are separate items from the catalogue entry. This enables tracking multiple copies per branch with individual status (available/checked_out) and condition, while the Book entity maintains catalogue metadata.

Denormalised title in Checkouttrade-off

The book title is duplicated in the Checkout item to avoid an extra GetItem call when displaying checkout lists. Trade-off: if the title changes (rare), checkouts will show the old title.

Alternative: Sparse index for overduealternative

Instead of querying GSI1 with date conditions, you could use a sparse index where only overdue items have the GSI key populated. This reduces GSI storage but requires an update when items become overdue.

Taught in the course

library-managementDynamoDB workbench
Ready to run
Explore an access patternSelect to load & run

List all library members registered at a specific branch

Request
Execute against the local Dynoxide engine
ReturnedFiltered outChanged
PK(pk)
SK(sk)
cardNumber
issuedAt
patronId
address
branchId
city
createdAt
name
openingHours
phone
GSI1PK
email
firstName
lastName
maxCheckouts
membershipTier
GSI1SK
checkoutDate
checkoutId
copyId
dueDate
isbn
renewalCount
title
author
description
genre
pageCount
publishYear
publisher
GSI2PK
GSI2SK
acquiredDate
condition
status
CARD#LIB-2024-0001
CARD#LIB-2024-0001S
LIB-2024-0001S
2026-08-05T14:30:00ZS
p-001S
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
BRANCH#br-downtown
BRANCH#br-downtownS
—
—
—
100 Main StreetS
br-downtownS
SpringfieldS
2022-08-10T00:00:00ZS
Downtown Public LibraryS
{7}M
555-0100S
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
BRANCH#br-downtown
COPY#copy-001S
—
—
—
—
br-downtownS
—
—
—
—
—
—
—
—
—
—
—
—
—
—
copy-001S
—
978-0-06-112008-4S
—
—
—
—
—
—
—
—
BOOK#978-0-06-112008-4S
BRANCH#br-downtownS
2025-08-10S
goodS
checked_outS
BRANCH#br-downtown
PATRON#p-001S
LIB-2024-0001S
—
p-001S
—
—
—
2026-08-05T14:30:00ZS
—
—
—
PATRON#p-001S
sarah.chen@email.comS
SarahS
ChenS
10N
premiumS
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
BRANCH#br-downtown
PATRON#p-002S
LIB-2024-0002S
—
p-002S
—
—
—
2026-09-15T09:15:00ZS
—
—
—
PATRON#p-002S
marcus.r@email.comS
MarcusS
RodriguezS
5N
basicS
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
BRANCH#br-westside
BRANCH#br-westsideS
—
—
—
500 Oak AvenueS
br-westsideS
SpringfieldS
2024-12-25T00:00:00ZS
Westside BranchS
{7}M
555-0200S
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
BRANCH#br-westside
COPY#copy-002S
—
—
—
—
br-westsideS
—
—
—
—
—
—
—
—
—
—
—
—
—
—
copy-002S
—
978-0-06-112008-4S
—
—
—
—
—
—
—
—
BOOK#978-0-06-112008-4S
BRANCH#br-westsideS
2026-07-31S
newS
availableS
PATRON#p-001
CHECKOUT#chk-001S
—
—
p-001S
—
—
—
—
—
—
—
PATRON#p-001S
—
—
—
—
—
CHECKOUT#2026-10-09S
2026-09-23T10:00:00ZS
chk-001S
copy-001S
2026-10-09S
978-0-06-112008-4S
0N
To Kill a MockingbirdS
—
—
—
—
—
—
—
—
—
—
—
BOOK#978-0-06-112008-4
BOOK#978-0-06-112008-4S
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
—
978-0-06-112008-4S
—
To Kill a MockingbirdS
Harper LeeS
A gripping tale of racial injustice in the American South.S
FictionS
281N
1960N
Harper PerennialS
—
—
—
—
—
Awaiting request
Your next query starts here.

Choose an access pattern above, or build your own request. See what comes back and what it costs.

Write transactions, streams, tags and TTL are among the operations this browser build leaves out. dynoxide's native build has them.