inflearn logo

If you understand normalization but don’t know where to start with order, refund, and settlement tables—practical commerce data modeling, from requirement 1/38 through 38/38

I’ve learned the principles of database design, but how do I turn orders, refunds, and settlements into tables? We’ll evolve the schema over 41 steps so a single order can flow through payment, partial cancellation, returns, refunds, and settlement, meeting all 38 requirements one by one.

1 learners are taking this course

Level Intermediate

Course period Unlimited

MySQL
MySQL
database-modeling
database-modeling
data-modeling
data-modeling
database-design
database-design
backend
backend
MySQL
MySQL
database-modeling
database-modeling
data-modeling
data-modeling
database-design
database-design
backend
backend

What you will gain after the course

  • Design snapshot fields so past orders and settlements remain unchanged even if the price, options, supplier, or commission rate changes.

  • We reconcile payment records based on a one-to-many relationship between orders and payments, partial cancellations, idempotency keys, and payment gateway reconciliation.

  • Model cancellations, returns, and exchanges as claims and claim items, and enforce state transition rules at the data level.

  • Allocate coupon discounts and reward points across items, and define rounding rules to document the basis for refund calculations.

  • Track partial shipments, supplier direct shipments, and return pickups in a single outbound structure, and validate shipped quantities.

  • Design revenue recognition based on purchase confirmation, supplier settlement, post-close adjustment entries, and audit logs.

  • We run twelve SQL checks for amount and quantity consistency every day, and incorporate new requirements as schema changes with regression testing.

I’ve learned database design principles, but how do I model orders, refunds, and settlements as tables?

We evolve a virtual shopping mall schema through 41 migration steps, passing 38 requirements one by one, so that a single order can flow through payment, partial cancellation, returns, refunds, purchase confirmation, and settlement. We run all SQL directly on Docker MySQL.

If you apply normalization exactly as you learned it in a database design course, it can actually cause problems with order data. You raise a product’s price, and the amounts on past orders change. You cancel one pair of socks from an order that used a coupon, and it refunds an extra 455 won. A settlement statement that was already finalized gets recalculated after a new contract is signed. In each lesson, this course first demonstrates scenarios like these by running actual SQL, then applies the schema changes needed to address them using step-by-step files, and finally verifies the results with requirement checks and data integrity validation SQL. It follows the story of a single schema and a single order from beginning to end.

By the end of this lesson, you will be able to

  • We’ll design snapshot fields so past orders and settlements don’t change when prices, options, suppliers, or commission rates change.

  • Order 1: N Payments — reconcile payment records using partial cancellations, idempotency keys, and payment gateway reconciliation.

  • Model cancellations, returns, and exchanges as claims and claim line items, and enforce state transition rules through data.

  • Allocate coupon discounts and reward points by product, and define rounding rules to document the basis for calculating refund amounts.

  • Track partial shipments, supplier direct deliveries, and return pickups in a single fulfillment structure, and validate shipped quantities.

  • Design revenue recognition based on purchase confirmation, supplier settlements, post-closing adjustment entries, and audit logs.

  • Run twelve SQL checks for amount and quantity consistency every day, and incorporate new requirements as schema changes with regression testing.

Recommended for people like you

  • A backend developer who has taken a database design course but has never designed order, payment, refund, and settlement tables firsthand.

  • A developer who has just joined an e-commerce company and needs to get up to speed on its order data structure.

  • A data analyst who wants to understand from the table structure why sales and refund figures don’t match.

  • A PM working on order and claim planning who wants to understand how the data is recorded

Curriculum (7 sections · 40 lessons · approximately 307 minutes)

  • Section 1. Getting Started: One Order and the Initial Schema — Complete Demo: One Order Through Settlement, Your First Order in 5 Minutes, 36 Requirements and the Initial Schema, Migration Checkpoints, Separating Orders from Order Items, Never Store Money in FLOAT

  • Section 2. Products, Pricing, and Status — Products, Options, and SKUs, Price Snapshots, Option Name and Additional Charge Snapshots, Store the Breakdown of the Amount to Be Paid, Status Belongs to Items, Not Orders, Status History: When Did It Change

  • Section 3. Payments — One order, multiple payments, loyalty points ledger, partial cancellation: never overwrite an authorization, idempotency keys: double-clicking still results in one payment, payment gateway reconciliation, SQL for validating payment consistency

  • Section 4. Claims and Refunds — Claim model: Don’t change quantities, claim state transition table, exchanges: what for what, allocating coupon discounts and 455 won, allocating reward points and rounding differences, refund table: keep the calculation basis

  • Section 5. Shipping — Partial shipments: shipments and shipment items, direct shipping from suppliers, delivery events and timestamps, return pickups as shipments, return shipping fee policies, shipment quantity consistency

  • Section 6. Coupons and Settlement — Coupon policies, issuance, and use; coupon conditions as data; when to recognize sales: purchase confirmation; supplier settlement and commission rate snapshots; returns after closing: adjustment entries

  • Section 7. Operations and Capstone — audit logs, daily consistency checks and known exceptions, summary tables for queries, Capstone ①: new requirements and gift orders, Capstone ②: loyalty point expiration and full regression testing

Practice Environment

We launch MySQL 8.4 with Docker and update the schema for the fictional sports and outdoor specialty store “Loop Market” one stage file at a time in each lesson. Run `./db.sh reset N` to return to the state for starting any lesson; `./reqs.sh` shows how many requirements it can handle, and `./verify.sh` shows the results of the amount and quantity consistency checks. Every number and error message shown in the lesson materials comes from actually running this exercise.

Prerequisites

  • Basic Concepts of Normalization

  • SQL JOINs and GROUP BY

  • A computer with Docker installed (to run the practice database)

What This Course Does Not Cover

  • Inventory deduction concurrency and lock handling

  • Query tuning and execution plans

  • Distributed transactions and message queues

  • How to integrate with a specific payment gateway

  • ORM Mapping

Notice

The slide narration is synthesized speech. All data is fictional training data, and numbers may vary depending on the execution environment.

Recommended for
these people

Who is this course right for?

  • A backend developer who has taken a database design course but has never designed order, payment, refund, or settlement tables firsthand.

  • A developer who has just joined an e-commerce company and needs to first understand its order data structure.

  • A data analyst who wants to understand why sales and refund figures don’t match by looking at the table structure

  • A PM working on order and claims planning who wants to understand how data is captured.

Need to know before starting?

  • Basic Concept of Normalization

  • SQL JOINs and GROUP BY

  • A computer with Docker installed (for running the practice database)

Hello
This is dorian05202988

Career Verified

A data craftsman with over 20 years of experience in databases and IT. As a DBA and manager of a DB Platform team, I work with database platforms and specialize in MySQL, PostgreSQL, Oracle, MongoDB, SQL tuning, AWS, Terraform, and Python. Drawing on experience in the gaming, finance, and IT services industries, I explain database and cloud architecture. I have published 『Oracle Practical Tuning: Learning SQL Patterns』 and 『Oracle Pro*C Practical Project Guide』, and have presented on serverless architectures, database selection, and multi-database strategies at AWS Summit 2018 and 2019 and DataYa Nolja 2020. Recently, I have been working on slow-query analysis and tuning recommendations using Bedrock LLM, automated DB specification sizing, and query workflows through a DB metadata MCP server and Slack bot. I explain database automation for developers and AI applications for non-developers through hands-on exercises tailored to the audience and objectives of each course. Rather than applying AI suggestions as-is, I teach a decision-making framework that verifies result equivalence, execution plans, and observability conditions, and defers action when the supporting evidence is insufficient. Company operational data and credentials are not included in the course materials.

More

Curriculum

All

40 lectures ∙ (5hr 8min)

Course Materials:

Lecture resources
Published: 
Last updated: 

Reviews

Not enough reviews.
Please write a valuable review that helps everyone!

dorian05202988's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

Limited time deal

$38.50

30%

$55.00