Skip to content

KPI dashboardsMySQL · Retail and consumer goods

Days of stock coverage per item, from an online shop's MySQL database

The orders, variants and stock of an online shop often sit in a MySQL or MariaDB database. This page explains how to derive from it, every day, the days of coverage of each item, the items about to run out and those that have not moved for too long, with an alarm that opens below the threshold and closes when the goods arrive.

By Muvia · Updated October 22, 2026

The use case: Stock coverage and low-stock alarms

The indicator: days of coverage

Days of coverage say how many days the available stock will last if sales continue at the recent pace. Compared with the replenishment lead time, they say when to reorder.

Available = stock on hand − quantity committed to unshipped orders

Average daily sales = pieces sold in the last N days ÷ N

Days of coverage = available ÷ average daily sales

Reorder point = average daily sales × lead time + safety stock

The guide to days of inventory coverage explains how to choose N and size the safety stock, and has a calculator.

What the dashboard shows

  • Most exposed items: the variants with fewer days of coverage than their lead time, ordered by the sales that could be lost.
  • Coverage by category and brand, to see where the catalogue is unbalanced.
  • Stock-outs: items at zero, for how many days, and how much they sold before.
  • Overstock: items with months of coverage, where capital sits idle.
  • Low-stock episodes: when they opened, when they closed and who handled them.

The data you need from the database

DataTypical fieldsWhat it is for
Products and variantscode, variant (size, colour), category, brandCalculating coverage at the level you reorder
Stockvariant, warehouse, quantity, last updateThe available quantity
Orders and linesdate, status, variant, quantity, channelAverage sales and committed stock
Returnsorder, variant, quantity, dateCorrecting sales and stock

Lead times and safety stock per supplier or family often sit in an Excel file, loaded as a source of its own.

The steps in Muvia

  1. In New source choose MySQL/MariaDB, give the server and a read-only user, and select the tables for products, stock, orders and returns. Muvia copies them on the schedule you choose, incrementally and over an encrypted TLS connection, without querying the shop each time the dashboard opens.

  2. Add the Excel file with lead times and thresholds per family.

  3. A query calculates available stock, average sales and days of coverage per variant, and becomes a dataset with stable fields.

  4. The dashboard shows the most exposed items; every Monday a PDF report goes to whoever reorders.

  5. An alarm opens when an item drops below the coverage threshold and closes on its own when stock goes back above it; the register says who handled it.

The pitfalls of an online shop's database

  • Days at zero in the average: if an item was out of stock for a week, average sales fall and coverage looks better. Calculate the average only over days with stock.
  • Order statuses: cancelled, unpaid or pending orders must be excluded or treated as committed, with an explicit rule.
  • Bundles: a kit sold draws down its components; if the database records only the kit, the components' coverage must be rebuilt from the bill of materials.
  • Deleted rows: new or changed rows reach the copy, deleted ones do not. If the shop deletes cancelled orders instead of changing their status, you need a periodic check or a full reload.
  • Several warehouses: coverage per warehouse and in total say different things; show both.

Frequently asked questions

Muvia does not query the database each time the dashboard opens: it copies the tables on a schedule, incrementally. Many choose to connect to a read-only replica, if there is one.

Bring us a question you can't answer today.

We start from a real question your business has and walk the path from source to dashboard with your systems, not a demo dataset.