accesspatterns.dev
← All models

general

URL Shortener

A hash-only table keyed by short code, the classic key-value lookup.

The simplest single-table design: a partition key and no sort key. Each item maps a short code to a long URL plus a click counter. There is no Query here, only GetItem by code.

The model

ShortLink

A short code mapping to a long URL.

pk
<code>

Attributes: code (S), longUrl (S), clicks (N)

Access patterns

  • GetItemResolve a short code

    Fetch the long URL for a short code.

Design notes

Why hash-onlywhy

Every read is a GetItem by the full key, so there is no sort key to carry. Adding one would cost storage and buy nothing for this access pattern.

Taught in the course

url-shortener

These rows are real and already here. Running an operation against them downloads a DynamoDB-compatible engine, about 850 KB, and executes it in this tab.

Try an example

Fetch the long URL for a short code.

code(pk)
clicks
longUrl
abc123
42N
https://example.com/pricingS
k3n9qz
1284N
https://example.com/blog/single-table-designS
r7wm2p
917N
https://example.com/docs/getting-startedS
b4xh8t
63N
https://example.com/careers/engineeringS
z2fq5v
3401N
https://example.com/blog/why-we-moved-off-sqlS
m8ct6j
205N
https://example.com/changelog/2026-06S
p5vd1w
88N
https://example.com/events/summitS
t9gk4r
1502N
https://example.com/docs/api/queryS
w6bz3n
17N
https://example.com/support/contactS
h1ju7s
2260N
https://example.com/blog/hot-partitionsS
n4rp9d
9N
https://example.com/legal/termsS
c7ys2k
744N
https://example.com/downloads/cliS

Run an operation to see the raw engine response.

table url-shortenerkeys codeitems 12

Transactions, streams, tags and TTL are among the operations the in-browser engine doesn't implement yet.