All projects Case study · Course project · Information System Design

Expiry-Aware Inventory
for Fresh Food

Fresh groceries spoil in days, and the same product sits in the warehouse in batches with different expiry dates. For a Market Kurly–style dawn-delivery service, we designed a system that tracks every batch, ships the soonest-to-expire stock first, discounts items as they near expiry, and records every disposal. We took it from requirements and data model through decision rules to working SQL and an admin dashboard.

Duration
Mar – Jun 2026
Team
3 students
My role
ER Modeling, Dashboard Design
Methods
Requirements analysis · DFD · ER modeling · Normalization · Decision tables
Tools
MySQL Workbench
Context
Information System Design course, Korea University
01

Background & Problem

Background

Dawn and same-day delivery have moved fresh groceries online. Services like Market Kurly promise produce, dairy, and meat that are only days from expiry, so every day in the warehouse counts.

Problem

Short shelf lives cause both stockouts and waste. Counting units per product isn’t enough: 75 strawberries may be 30 that expire tomorrow and 45 that last three more days. Every unit thrown away adds disposal cost and environmental harm.

Key question: How can one system manage expiry dates, stock, shipments, and disposals together, so near-expiry stock leaves the warehouse before it spoils?

02

Requirements

We split the requirements by who acts: what the warehouse manager needs to see and record, and what the system must decide on its own.

  • R1 · ManagerSee current stock and expiry dates per product, to spot shortages and items at risk.
  • R2 · ManagerSee a list of near-expiry items, which the system flags once they fall within a set number of days.
  • R3 · ManagerRecord and review disposals with quantity, reason, and date.
  • R4 · SystemWhen a shipment request comes in, check whether enough usable stock exists.
  • R5 · SystemShip from the batch closest to expiry first (FEFO), and log each shipment.
  • R6 · SystemApply preset discounts to near-expiry items automatically, and show the manager which items are discounted.

Scope

The system does

  • Track stock and expiry by batch
  • Check shippable stock for each order
  • Ship the soonest-to-expire batch first
  • Set discounts by days left and stock
  • Log disposals and surface items often wasted

The system does not

  • Manage suppliers or create purchase orders
  • Optimize delivery routes
  • Give personalized coupons to customers
  • Forecast demand with AI
03

System Design

How data moves

The data flow diagram links four processes (order, payment, inventory, and shipping) to the customer, payment gateway, and shipping provider. Inventory management sits at the center: it answers stock requests with pickable stock, reads expiry dates and stock levels, and writes disposal records.

Data flow diagram with four processes: process order, handle payment, manage inventory, and ship order

How data is stored

Seven entities: Admin, Product, Discount policy, Inventory, Shipment request, Shipment, and Disposal.

ER diagram of seven entities: admin, product, discount policy, inventory, shipment request, shipment, disposal
Decision 1Track batches, not products

Each Inventory row is one received batch with its own expiry date and remaining quantity. Without batches, FEFO and expiry-based discounts can’t be computed.

Decision 2Keep request and shipment apart

One request can be filled from several batches, so a Shipment request (with status Pending / Complete / Unavailable) links to one or more Shipment rows.

04

Normalization

We normalized the schema step by step to Third Normal Form so that a price or discount changes in one place, not in every table that copied it.

  • 1NF · Non-atomic valueOne discount cell held two rules: “≤3 days → 30%, ≤1 day → 50%”One value per cellSplit into a column per threshold
  • 2NF · Repeating columnsDiscount columns repeated for each threshold on the productDiscount policy tableOne row per product and threshold
  • 3NF · Transitive dependencyProduct name and price copied into Inventory, Request, Shipment, and DisposalReference by keyThose tables keep only the product ID as a foreign key
Final relation schema 7 tables · PK, FK
TableColumns
Adminadmin_id, name, email, phone, registered_at
Productproduct_id, product_name, category, unit_price
Discount policypolicy_id, product_id, days_left, discount_rate
Inventoryinventory_id, product_id, received_date, expiration_date, received_qty, current_quantity, unit_cost
Shipment requestrequest_id, admin_id, product_id, request_quantity, requested_at, request_status
Shipmentshipment_id, request_id, inventory_id, shipment_quantity, shipped_at
Disposaldisposal_id, inventory_id, admin_id, disposal_quantity, disposal_reason, disposal_date, note
05

Rules & Logic

Three rules drive the system. We wrote each as a decision table first, so every combination of conditions had a defined outcome, including edge cases like a zero-quantity request or a product whose every batch has expired. Figure 1 shows all three on one sample order.

Rule 1 sets price by days left: full price at 4 or more days, 30% off at 3 to 2 days, 50% off at 1 day, disposal at 0. Rule 3 ships 30 units from batch 1, which expires in 1 day, then 10 from batch 2, which expires in 3 days. Rule 2 marks the request complete because 75 usable units cover the 40 requested. RULE 1 Price by days left Full price 30% off 50% off Dispose 4+ days left 3 2 1 0 · expires today RULE 3 FEFO picking Request: 40 strawberries Sample data, 6 Jun 2026 Batch #245 units Batch #130 units next-closest ① ship all 30 ② ship 10 more RULE 2 Ship or not Usable stock 30 + 45 = 75 ≥ 40 requested → status: Complete If usable stock falls short, or every batch has expired, the request is marked Unavailable.
Figure 1. The three rules applied to one strawberry order from our sample data.
Decision tables 3 tables
Table 1 · Discount by days left
Conditions / Actions12345
Expires today (0 days left)NNNYY
≤ 1 day leftNNY––
≤ 3 days leftNYY––
Stock > 0YYYYN
No discountX
30% offX
50% offX
Mark for disposalXX
Table 2 · Shipment request
Conditions / Actions12345
Total stock ≥ requestedYNYN–
Unexpired stock existsYYNN–
Requested quantity > 0YYYYN
Status → CompleteX
Status → Unavailable (short stock)XX
Status → Unavailable (all expired)X
Status → Unavailable (invalid request)X
Run FEFO pickingX
Table 3 · FEFO batch selection
Conditions / Actions12345
2+ batches of the productYYYNN
First batch covers the remainderYN–YN
First batch not expiredYYNYY
Ship all from first batchXX
Ship part, move to next batchX
Skip batch, flag for disposalX
Log shipment, deduct stockXXX

Y = yes · N = no · – = doesn’t matter · X = action runs

Pseudocode 3 procedures Find near-expiry items and apply discounts
DO
  READ TABLE (inventory, product, discount_policy)
  FIND inventory WHERE expiration_date >= TODAY
  SET days_left = DATEDIFF(expiration_date, TODAY)

  IF days_left = 0
    SET action = 'dispose'
  ELSEIF days_left <= 1
    SET rate = discount_policy.rate WHERE days_left = 1   // 50%
  ELSEIF days_left <= 3
    SET rate = discount_policy.rate WHERE days_left = 3   // 30%
  ELSE
    SET rate = 0                                          // no discount
  END IF
  PRINT product_name, inventory_id, days_left, rate / action
UNTIL end of file
Decide whether a request can ship
DO
  READ TABLE (shipment_request, inventory, product)
  FIND shipment_request WHERE status = 'Pending'

  // usable stock = unexpired batches with units left
  SET available = SUM(inventory.current_quantity)
                  WHERE product_id = request.product_id
                    AND current_quantity > 0
                    AND expiration_date >= TODAY

  IF request.quantity <= 0
    UPDATE status = 'Unavailable'                // invalid request
  ELSEIF available >= request.quantity
    UPDATE status = 'Complete'
    CALL FEFO_ship(request_id, product_id, request.quantity)
  ELSE
    UPDATE status = 'Unavailable'                // short or expired stock
  END IF
UNTIL end of file
FEFO_ship: closest expiry first
// FEFO_ship(request_id, product_id, quantity)
SORT inventory BY expiration_date ASC
  WHERE product_id = product_id
    AND current_quantity > 0
    AND expiration_date >= TODAY
SET remaining = quantity

FOR EACH batch IN sorted inventory
  IF remaining <= 0 THEN BREAK
  SET qty = MIN(batch.current_quantity, remaining)
  INSERT INTO shipment (request_id, batch.inventory_id, qty, NOW)
  UPDATE inventory SET current_quantity = current_quantity - qty
    WHERE inventory_id = batch.inventory_id
  SET remaining = remaining - qty
END FOR
06

Implementation

We had no access to Kurly’s internal data, so we built the database in MySQL with sample data designed to trigger every case: near-expiry items, both discount tiers, shippable and short-stock requests, a FEFO shipment split across batches, and one disposal for each reason. Six queries checked the rules against it.

  • Stock by productTotals across batches for six products, e.g. strawberries 75, tofu 8.
  • Near-expiry itemsFive batches within 3 days, soonest first. Tofu expires today.
  • Automatic discounts50% at ≤1 day and 30% at ≤3 days. Strawberries expiring tomorrow drop from ₩5,000 to ₩2,500.
  • Can it ship?Five requests checked. Milk: 90 requested, 80 in stock, so Unavailable.
  • FEFO shipment logStrawberries 40 → 30 from the batch expiring 7 Jun, then 10 from 9 Jun. Salad 60 → 25 + 35.
  • Disposal logThree records: expired, damaged packaging, and failed inspection.
SQL queries 6 queries 1 · Stock by product
SELECT p.product_name, p.category,
       SUM(i.current_quantity) AS total_stock
FROM product p
JOIN inventory i ON p.product_id = i.product_id
GROUP BY p.product_id, p.product_name, p.category;
2 · Near-expiry items (≤ 3 days)
SELECT p.product_name, i.inventory_id, i.expiration_date,
       DATEDIFF(i.expiration_date, '2026-06-06') AS days_left,
       i.current_quantity
FROM inventory i
JOIN product p ON i.product_id = p.product_id
WHERE DATEDIFF(i.expiration_date, '2026-06-06') <= 3
  AND i.current_quantity > 0
ORDER BY i.expiration_date;
3 · Automatic discounts
SELECT p.product_name, i.inventory_id, i.expiration_date,
       DATEDIFF(i.expiration_date, '2026-06-06') AS days_left,
       CASE
         WHEN DATEDIFF(i.expiration_date, '2026-06-06') <= 1 THEN 0.50
         WHEN DATEDIFF(i.expiration_date, '2026-06-06') <= 3 THEN 0.30
         ELSE 0.00
       END AS discount_rate,
       p.unit_price AS list_price,
       p.unit_price * (1 - CASE
         WHEN DATEDIFF(i.expiration_date, '2026-06-06') <= 1 THEN 0.50
         WHEN DATEDIFF(i.expiration_date, '2026-06-06') <= 3 THEN 0.30
         ELSE 0.00
       END) AS sale_price
FROM inventory i
JOIN product p ON i.product_id = p.product_id
WHERE i.current_quantity > 0
ORDER BY i.expiration_date;
4 · Can each request ship?
SELECT sr.request_id, p.product_name, sr.request_quantity,
       SUM(i.current_quantity) AS total_stock,
       CASE WHEN SUM(i.current_quantity) >= sr.request_quantity
            THEN 'Shippable' ELSE 'Short stock' END AS shippable,
       sr.request_status
FROM shipmentrequest sr
JOIN product p   ON sr.product_id = p.product_id
JOIN inventory i ON sr.product_id = i.product_id
GROUP BY sr.request_id, p.product_name,
         sr.request_quantity, sr.request_status;
5 · FEFO shipment log
SELECT s.shipment_id, sr.request_id, p.product_name,
       i.inventory_id, i.expiration_date,
       s.shipment_quantity, s.shipped_at
FROM shipment s
JOIN shipmentrequest sr ON s.request_id = sr.request_id
JOIN inventory i        ON s.inventory_id = i.inventory_id
JOIN product p          ON i.product_id = p.product_id
ORDER BY sr.request_id, i.expiration_date;
6 · Disposal log
SELECT d.disposal_id, p.product_name, i.inventory_id,
       d.disposal_quantity, d.disposal_reason,
       d.disposal_date, d.note
FROM disposal d
JOIN inventory i ON d.inventory_id = i.inventory_id
JOIN product p   ON i.product_id = p.product_id
ORDER BY d.disposal_date;

Admin dashboard

The dashboard turns the queries into one screen for the warehouse manager. Four counts sit on top (total stock, near-expiry stock, pending requests, today’s disposals), and each panel below answers one requirement.

Admin dashboard with stock by product, near-expiry discounts, shipment request status, and disposal log
  • Stock by product (R1): totals per product and category
  • Near-expiry & discounts (R2, R6): days left in red or amber, with the discount tier as a badge
  • Shipment requests (R4, R5): each request’s status as Complete, Pending, or Unavailable
  • Disposal log (R3): quantity, reason, and date
07

Limitations & Reflection

What I did

  • [Your contribution 1, e.g. requirements and decision tables]
  • [Your contribution 2, e.g. ER model and normalization]
  • [Your contribution 3, e.g. dashboard design]

Limitations

The system covers stock, shipping, and disposal only. It doesn’t forecast demand, place orders, or plan delivery routes, and it was tested only on sample data. Discount thresholds are fixed by hand, though the disposal log could later be used to tune them per product.

Reflection

Designing the rules before the screens made the dashboard simple: every panel maps to a requirement, and every number is a query we had already tested. Decision tables did the same for edge cases. Listing every combination exposed cases that would otherwise hide behind a generic error, like a request for zero units or a product whose stock had all expired.

We designed for a manager we never met. Next, I would watch warehouse staff during an early-morning shift to learn which numbers they actually check first, and test whether the dashboard helps them act on near-expiry stock in time.

NextBack to all projects