---
title: "Sample database: e-commerce"
description: "The CoraDB e-commerce sample database used by the examples: a hybrid schema of tables, vertex and edge tables, row counts and loading."
url: "https://www.coradb.ai/manual/sample-database.html"
markdown_url: "https://www.coradb.ai/manual/markdown/sample-database.md"
product: "CoraDB"
version: "1.0"
keywords: "coradb sample database, e-commerce database, demo database, graph sample data, hybrid relational graph schema, coradb tutorial data"
---

# Sample database: e-commerce

The **e-commerce** database is the sample database used throughout this manual. It models an online store for athletic apparel and gear (with a small grocery corner): customers order products, products belong to categories, brands manufacture products and suppliers distribute brands, and everything is located in cities. It also records two *social* signals: which brands a customer **follows** and which products a customer **likes**.

The schema is deliberately **hybrid**, to show relational and graph data side by side in one database:

- **Transactional data** (`orders`, `order_items`) and the `countries` lookup are **relational tables**, queried with standard SQL.
- **Master data** (`customer`, `product`, `category`, `brand`, `supplier`, `city`) are **vertex tables**, connected by nine kinds of **edges**, and are queried with [SELECT … MATCH](https://www.coradb.ai/manual/graph/match.html).
- Vertex tables can also be read like ordinary tables, and a single query can [combine graph patterns with relational tables](https://www.coradb.ai/manual/graph/match.html#joining-match-patterns-and-tables).

![Schema of the e-commerce sample database: six vertex tables (city, customer, brand, product, supplier, category) linked by nine edge types, and three relational tables (orders, order_items, countries) linked by foreign keys](https://www.coradb.ai/manual/_astro/e-commerce-schema.B-UwYIEG.svg)

## At a glance

| Object type | Count | Rows |
|---|---:|---:|
| Relational tables | 3 | 14,114 |
| Vertex tables | 6 | 3,397 nodes |
| Edge tables | 9 | 12,808 edges |

## Relational tables

| Table | Columns | Rows |
|---|---|---:|
| `orders` | `id` INT PK, `customer_id` INT → `customer.id`, `order_date` DATE, `shipped_date` DATE (NULL = not shipped yet), `shipping_cost` DECIMAL(10,2), `ship_address` VARCHAR(128) | 2,910 |
| `order_items` | `order_id` INT → `orders.id`, `product_id` INT → `product.id`, `quantity` SMALLINT, `discount_pct` SMALLINT; PK (`order_id`, `product_id`) | 11,179 |
| `countries` | `code` VARCHAR(8) PK (ISO 3166 alpha-3), `name` VARCHAR(32) | 25 |

## Vertex tables (nodes)

| Vertex table | Columns | Rows |
|---|---|---:|
| `customer` | `id` INT PK, `company_name`, `contact_name`, `contact_title`, `address`, `phone` | 1,000 |
| `product` | `id` INT PK, `name` VARCHAR(64), `description` VARCHAR(32), `unit_price` DECIMAL(10,2), `units_in_stock` SMALLINT | 2,115 |
| `category` | `id` INT PK, `name`, `description` | 32 |
| `brand` | `id` INT PK, `name` | 106 |
| `supplier` | `id` INT PK, `company_name`, `contact_name`, `contact_title`, `address`, `phone` | 29 |
| `city` | `id` INT PK, `name`, `region`, `postal_code`, `country_code` → `countries.code` | 115 |

## Edge tables (relationships)

Every edge has one property, `since` (DATETIME): when the relationship was recorded.

| Edge | From → to | Cardinality | Meaning | Rows |
|---|---|---|---|---:|
| `part_of` | product → category | N:M | A product belongs to a category | 3,618 |
| `manufactures` | brand → product | N:M | A brand makes a product | 2,135 |
| `available_at` | product → supplier | N:1 | A product is sold by a supplier | 2,115 |
| `distributes` | supplier → brand | N:1 | A supplier distributes a brand | 29 |
| `follows` | customer → brand | N:M | A customer follows a brand | 1,934 |
| `likes` | customer → product | N:M | A customer likes a product | 1,842 |
| `resides_in` | customer → city | N:1 | A customer lives in a city | 1,000 |
| `located_in` | supplier → city | N:1 | A supplier is based in a city | 29 |
| `located_at` | brand → city | N:1 | A brand is based in a city | 106 |

The relational tables link to the graph through foreign keys, not edges: `orders.customer_id` → `customer.id`, `order_items.product_id` → `product.id`, and `city.country_code` → `countries.code`.

## About the data

The data is synthetic but statistically realistic: orders follow a Pareto distribution per customer (a few frequent buyers, a long tail and about 35% of customers who never order), with holiday seasonality and growth from 2021 to 2025; most order lines have a quantity of 1 to 3 and about 70% have no discount; a few recent orders are still unshipped; and `follows` / `likes` are skewed signals correlated with buying. Product names are real-sounding catalog names (for example *Chaz Kangaroo Hoodie*), and brands are well-known apparel labels (Nike, Adidas, Under Armour, Lululemon, Patagonia …).

## Get the database

The e-commerce database is one of the [demo databases](https://www.coradb.ai/manual/demo-databases.html) included with CoraDB: it is already created and loaded. Start its server if it is not running, then connect with the [corasql interpreter](https://www.coradb.ai/manual/corasql.html):

```bash
coradb server start e-commerce
corasql -u dba e-commerce
```

Check the content:

```sql
SELECT (SELECT COUNT(*) FROM orders) AS orders,
       (SELECT COUNT(*) FROM customer) AS customers,
       (SELECT COUNT(*) FROM product) AS products;
```

| orders | customers | products |
|---:|---:|---:|
| 2910 | 1000 | 2115 |

## First queries

A relational query: orders per year.

```sql
SELECT EXTRACT(YEAR FROM order_date) AS yr, COUNT(*) AS orders
FROM orders
GROUP BY yr
ORDER BY yr;
```

A graph query: the brands with the most followers.

```sql
SELECT b.name, COUNT(cu) AS followers
FROM MATCH (cu:customer)-[:follows]->(b:brand)
GROUP BY b.name
ORDER BY followers DESC
LIMIT 5;
```

A hybrid query: the best-selling products with their category (graph `part_of` edge + relational `order_items`).

```sql
SELECT p.name AS product, c.name AS category, SUM(oi.quantity) AS total_sold
FROM MATCH (p:product)-[:part_of]->(c:category),
     order_items oi
WHERE oi.product_id = p.id
GROUP BY p.name, c.name
ORDER BY total_sold DESC
LIMIT 10;
```

Continue with [SELECT](https://www.coradb.ai/manual/sql/query/select.html) and [MATCH clause: graph queries in SELECT](https://www.coradb.ai/manual/graph/match.html).
