Amazon DynamoDB Conditional Writes: Keep Museum Accession IDs Unique

One Accession Number Should Not Silently Replace Another

A museum imports two catalog submissions whose spreadsheets accidentally assign the same accession identifier to different donated objects. If an integration issues an unconditional PutItem for the second row, it risks overwriting the original item at that key. Amazon DynamoDB condition expressions can prevent that particular mistake by requiring a condition to be true before a write proceeds. The registry still needs a human process for deciding which real object owns the identifier. A rejected conditional write is a collision signal, not proof that either catalog entry is authentic. Here we use fabricated object IDs and an illustrative workflow rather than a claim of live database testing.

Start With the Exact Primary Key Boundary

DynamoDB evaluates a condition expression against the item identified by the write’s primary key. For a simple key, attribute_not_exists on that key can protect an identifier from being replaced by a second PutItem. With a composite partition-and-sort key, the condition is evaluated for the specific pair, not as a global uniqueness constraint across every item sharing one partition key. That distinction matters for museum databases that keep an institution code and accession code in different key positions. Model the key so uniqueness means what the archivists expect; do not assume a table-wide global constraint exists merely because the expression includes attribute_not_exists. Test duplicate submissions against the actual chosen schema.

Three-stage conceptual workflow for DynamoDB conditional writes: normalize the id, check absence, review conflict.

Use a Conditional PutItem for First Registration

For a straightforward accession registry, the first registration may require a PutItem with a condition like attribute_not_exists(AccessionId), using the actual key attribute name. If a record with that key exists, DynamoDB rejects the conditional write instead of silently overwriting it. Handle that rejected condition explicitly in the importer: mark a candidate as a conflict, retain a pointer to the original source row, and send both versions for editorial review. A generic retry loop is a poor response to a meaningful conflict. Neither the failed condition nor its exception proves that the incoming image, donor statement, provenance, or object classification is right. It only says the requested write did not satisfy the stored-state condition.

Do Not Confuse Conditional Create With Conditional Update

Some institutions need to correct catalog metadata after approval. An update that is intentionally allowed is different from first registration. A condition may check the current version number or an expected review state, rejecting an edit if someone else has modified the row. The expression reference supports comparisons and attribute tests for PutItem, UpdateItem, and DeleteItem, but the chosen design must define what an editor is permitted to change. Never reuse a first-create condition for every update, and never turn a failed version check into a force overwrite. Show the editor the competing revisions, their sources, and the intended correction. This preserves auditability without pretending DynamoDB knows the institution’s cataloging policy.

Compare an Empty Key, a Collision and a Changed Version

Consider three hypothetical submissions. In the first, accession ARC-042 is absent and a conditional registration can proceed. In the second, ARC-042 already exists and the importer must reject the replacement and flag a collision. In the third, an editor attempts to change an existing entry based on version 2 while another editor has already saved version 3; a correctly designed version condition should block the stale update. These are different states and require different user messages. A diagram should not paint every blocked write red as a system failure: a guard doing its job is often a success for the archive. The examples are conceptual, not database logs or measured outcomes.

Hypothetical visual comparison for DynamoDB conditional writes: new accession, duplicate id, stale version; not measured test results.

Define Identifier Normalization Before the Write

Conditional writes operate on the keys and attributes an application sends. They cannot recognize that ARC-042, arc-042, and ARC 042 represent the same accession under a museum’s naming policy unless the importer normalizes them consistently first. Define a canonical identifier and keep the original notation as a separate field when historically relevant. Validate allowed prefixes, zero padding, institution code, and reserved ranges before constructing the key. Do not automatically merge two physical objects because their OCR text appears similar. If the import includes a scanned paper accession card, use it as evidence for a reviewer rather than assuming OCR supplies a definitive identifier. Only then should a conditional registration attempt occur.

Keep Permissions and Review Roles Outside the Condition

A successful conditional write shows that the stored-state condition was satisfied; it does not establish that the caller had the right to authorize a donation or publish the object’s description. Use IAM and application authorization to control which service accounts can propose records and which roles can approve them. Consider separating proposed registration from published catalog state so an imported object remains hidden until source documents and rights are checked. Record the job ID, source file revision, reviewer, and conflict resolution in an audit trail. Avoid placing private donor information in collision logs or public error messages. The database is one part of the chain, not the owner of legal provenance decisions.

Design a Human-Readable Collision Queue

When the conditional request fails, display a stable accession key, the existing record’s non-sensitive title, the proposed title, import source, and a link to compare evidence. Offer actions such as assign a corrected identifier, mark as a legitimate duplicate export, or ask a cataloger to investigate. Do not allow the importer to pick a new random accession automatically just to make the write pass; that could create a false historic record. For retried jobs, attach a separate idempotency token so rerunning an already accepted candidate does not generate a second proposal. Review the actual DynamoDB error and application state before labeling a failure as a collision, because permissions and service errors have different remedies.

Illustrated verification points for DynamoDB conditional writes: primary key, collision queue, authorization.

Audit the Guard With Controlled Duplicate Scenarios

A staging test should include a previously absent ID, an existing ID, two concurrent writers for the same key, and an update with a stale expected version. Confirm that a rejected condition leaves the stored record unchanged and produces an actionable review entry. Also check alternate punctuation and case variants after your normalization rule. Do not use sensitive donor records as test fixtures. This article documents the intended design, not tests we ran; validate the table schema, IAM grants, billing implications and operational behavior in the organization’s own environment. A conditional write can protect the integrity of a key, but a catalog becomes trustworthy only when evidence, permissions and review procedures surround that key.

How We Research

For this guide, we reviewed the official product documentation on November 8, 2026: AWS DynamoDB condition expressions, AWS DynamoDB expression overview, AWS DynamoDB expression functions. We checked the named setting or feature against its published behavior, mapped the documented constraints to the specific hypothetical scenario, and reviewed whether the topic duplicated titles in the supplied LabFin WordPress inventory or prior B0267–B0278 ZIPs. No authenticated vendor service was run; we did not perform a benchmark, observe real customer data, verify third-party rights or claim operational outcomes. All illustrated records and comparisons are teaching examples. Confirm product documentation and security requirements again before implementing a workflow in a real organization.

Frequently Asked Questions

Will an ordinary DynamoDB PutItem overwrite an existing item?

A PutItem using an existing primary key can replace the item unless the request includes an appropriate condition.

What does attribute_not_exists protect?

On a conditional write, it checks absence of the indicated attribute on the item identified by the request key; it is not global uniqueness across arbitrary fields.

Does a composite primary key change the uniqueness rule?

Yes. The condition is evaluated for the specific partition-key and sort-key pair, so model the keys deliberately.

What should an importer do after a conditional failure?

Distinguish a collision from other errors, preserve the existing row, and route the proposed record to review rather than force an overwrite.

Do conditional writes verify an artifact’s authenticity?

No. They enforce stored-state conditions; catalog provenance, ownership and permissions require human and application checks.

Scroll to Top