# Transactions and the Relational Choice

Keep a checkout from selling a bike that's already gone: see why a single-document update is already safe, and when a transaction is needed. Then, if you know SQL, see the same store designed both ways, and learn when a relational database is the better choice.

Updated: November 19, 2026

## [Transactions](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-transactions)

1. [Transactions, and Why You'll Need Them Less](https://www.ask-codey.com/lessons/mongodb-transactions-and-why-you-need-them-less) (Journeyman): When two shoppers reach for the last bike, a conditional updateOne keeps the stock right on its own, and when the stock and a new order must change together, a transaction makes both changes happen or neither.

## [If You Know SQL](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-if-you-know-sql)

1. [If You Know SQL: One Store Designed Both Ways](https://www.ask-codey.com/lessons/mongodb-if-you-know-sql-one-store-both-ways) (Journeyman): Riverbend Bike Shop's store as SQL tables beside the same store as MongoDB documents, the words that carry over from one to the other, and the relational habits that don't.
2. [If You Know SQL: Queries Side by Side](https://www.ask-codey.com/lessons/mongodb-if-you-know-sql-queries-side-by-side) (Apprentice): The SQL you already write beside its MongoDB twin, from SELECT with WHERE, ORDER BY and a row limit to INSERT, UPDATE and DELETE, with a first look at GROUP BY and JOIN in a pipeline.

## [Choosing Relational](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-choosing-relational)

1. [When a Relational Database Is the Better Choice](https://www.ask-codey.com/lessons/mongodb-when-relational-is-better) (Journeyman): An honest look at the apps where a relational database fits better than documents, such as money moving between many records, reports that join data in ways nobody planned, and a shape many teams must share, and why many apps use both.

## [Exercise: Checkout Without Overselling](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-exercise-checkout-without-overselling)

1. [Exercise: Checkout Without Overselling](https://www.ask-codey.com/lessons/exercise-mongodb-checkout-without-overselling) (Journeyman): Write the five statements behind Riverbend Bike Shop's checkout and cancel, from a stock update that never sells a bike twice to a restock, and let the tests run two checkouts at once and a cancel inside a transaction.

## [Up Next: Aggregation and Indexes](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-up-next-aggregation-and-indexes)

1. [Up Next: Aggregation and Indexes](https://www.ask-codey.com/lessons/mongodb-up-next-aggregation-and-indexes) (Journeyman): Look back at what Module 3 lets you design, see it applied to a whole store's screens, and see what Module 4 adds, reports built from a year of orders and indexes that keep them fast.

Source: https://www.ask-codey.com/courses/mongodb-in-depth/chapters/transactions-and-the-relational-choice
