Sales and Supply Networks
Use case · Trading, logistics and traceability
Sales and supply networks
A trading business is a network: suppliers provide products, customers place orders, employees sell and report to managers, shippers deliver.
Questions about traceability and performance follow those links: who supplied what a customer bought, who sold it, which products travel together.
Modeled as a graph, each of these questions is a path, and multi-step paths stay readable and fast.
- Trace products from supplier to customer
- Rank customers and employees by what they sold or bought
- Walk the management chain, at any depth
- Find the shortest connection between two people
nodes: customers, orders, products, suppliers, employees and more
edges, including order lines with quantity, price and discount
ready-to-run demo queries
See it in CoraDB
The questions, as queries.
Each query below runs as it is on the Northwind demo database.
-- Which suppliers provide products in the "Confections" category?
SELECT DISTINCT s.company_name
FROM MATCH (s:supplier)-[:supplies]->(p:product),
(p:product)-[:part_of]->(c:category)
WHERE c.category_name = 'Confections';
| company_name |
|---|
| Forêts d'érables |
| Heli Süßwaren GmbH & Co. KG |
| Karkki Oy |
| Pavlova, Ltd. |
| Specialty Biscuits, Ltd. |
-- Who are the top 5 customers by total order value?
SELECT cu.company_name,
SUM(oe.unit_price * oe.quantity * (1 - oe.discount)) AS totalValue
FROM MATCH (cu:customer)-[:purchased]->(o:`order`),
(o:`order`)-[oe:orders]->(p:product)
GROUP BY cu.company_name
ORDER BY totalValue DESC
LIMIT 5;
| company_name | totalValue |
|---|---|
| QUICK-Stop | 110277.31 |
| Ernst Handel | 104874.98 |
| Save-a-lot Markets | 104361.95 |
| Rattlesnake Canyon Grocery | 51097.80 |
| Hungry Owl All-Night Grocers | 49979.91 |
-- Show the full management chain above employee "Robert King".
SELECT m.first_name, m.last_name
FROM MATCH (e:employee)-[:reports_to{1,3}]->(m:employee)
WHERE e.last_name = 'King';
| first_name | last_name |
|---|---|
| Steven | Buchanan |
| Andrew | Fuller |
-- Find the shortest reporting connection between
-- "Robert King" and "Nancy Davolio".
SELECT k.first_name, k.last_name, n.first_name, n.last_name
FROM MATCH ANY_SHORTEST (k:employee)-[e:reports_to{1,4}]-(n:employee)
WHERE k.last_name = 'King' AND n.last_name = 'Davolio';
| k.first_name | k.last_name | n.first_name | n.last_name |
|---|---|---|---|
| Robert | King | Nancy | Davolio |
Why one engine
Operations data and its network, together.
Orders, invoices and stock levels are relational by nature; the network between suppliers, products, customers and people is a graph.
CoraDB keeps both in one engine, so a traceability question can start from an order table and follow the graph, in one statement and one transaction.
- No ETL into a separate graph database
- Graph results join straight to relational tables
- The same drivers and tools for both
Try it yourself
Download the Northwind demo database, load it into CoraDB and run the queries.
The Getting Started guide shows how, step by step.
Want to try it on your own data? Talk to us.