Use Cases /

Product Recommendations

Use case · New dual-data solutions

E-commerce product recommendations

One of the most important features of an e-commerce retail solution is the capability to provide high-quality recommendations for buying other products or items.
A system responsible for this feature is known as a Product Recommendations (PR) system.

A good PR system can significantly increase a website's profits by driving additional product sales to existing customers and by increasing the customer base.

Ultimately, from the end user's point of view, product recommendations provide this type of information:

  • Customers who bought this also bought this;
  • This product is usually bought together with this;
  • These are related recommended products.
-- Which products are most often ordered together with "Chai"?
SELECT p2.product_name, COUNT(o) AS timesTogether
FROM MATCH (p1:product)<-[:orders]-(o:`order`),
  (o:`order`)-[:orders]->(p2:product)
WHERE p1.product_name = 'Chai'
GROUP BY p2.product_name
ORDER BY timesTogether DESC
LIMIT 10;
graph pattern (PGQL)“Bought together with this” is one graph pattern: product → order → product.
Result10 rows, first 5 shown
product_nametimesTogether
Boston Crab Meat4
Flotemysost4
Sir Rodney's Scones4
Camembert Pierrot4
Tunnbröd3

See it in CoraDB

Recommendations are graph questions.

“Customers who bought this also bought”, “usually bought together” and “related products” are paths between customers, orders and products. In CoraDB you ask them with a MATCH pattern, on the same data your shop already keeps in tables. These queries run as they are on two of the CoraDB demo databases.

-- Find pairs of customers who like the same product.
SELECT c1.company_name AS customer1, c2.company_name AS customer2, p.name AS product
FROM MATCH
  (c1:customer)-[:likes]->(p:product),
  (c2:customer)-[:likes]->(p:product)
WHERE c1.id < c2.id;
graph pattern (PGQL)Collaborative filtering starts here: customers linked through what they like.
Result12762 rows, first 3 shown
customer1customer2product
Brown, Roman and AllenScott LtdSirop derable
Brown, Roman and AllenSandoval and SonsCirce Hooded Ice Fleece
Brown, Roman and AllenJones, Livingston and BrownCirce Hooded Ice Fleece
-- Which other customers have bought at least one of
-- the same products as "Ernst Handel"?
SELECT DISTINCT c2.company_name
FROM MATCH
  (c1:customer)-[:purchased]->(o1:`order`),
  (o1:`order`)-[:orders]->(p:product),
  (p:product)<-[:orders]-(o2:`order`),
  (o2:`order`)<-[:purchased]-(c2:customer)
WHERE c1.company_name = 'Ernst Handel'
AND c1 <> c2;
graph pattern (PGQL)A four-hop path that would take four joins and an ETL job with separate databases.
Result88 rows, first 5 shown
company_name
Alfreds Futterkiste
Ana Trujillo Emparedados y helados
Antonio Moreno Taquería
Around the Horn
B's Beverages
-- For customers who follow "Nike", show the products it makes,
-- each product's category, and the suppliers carrying them.
SELECT DISTINCT cu.company_name, p.name AS product,
       c.name AS category, s.company_name AS supplier
FROM MATCH
  (cu:customer)-[:follows]->(b:brand),
  (b:brand)-[:manufactures]->(p:product),
  (p:product)-[:part_of]->(c:category),
  (p:product)-[:available_at]->(s:supplier)
WHERE b.name = 'Nike';
graph pattern (PGQL)Content and relationships in one statement: brand, product, category and supplier.
Result7622 rows, first 3 shown
company_nameproductcategorysupplier
Adams, Lloyd and JordanAero Daily Fitness TeeTeesG'day Mate
Adams, Lloyd and JordanBella TankBras & TanksNorske Meierier
Adams, Lloyd and JordanBreathe-Easy TankBras & TanksNew England Seafood Cannery

Get the e-commerce demo database Get Northwind

Recommendation system flow

Two types of PR systems, by update frequency:

  • Offline systems update recommendation data periodically or on demand.
  • Real-time systems use graph databases and parallel processing for instant recommendation updates.

Recommendation systems

Three main models for product recommendation systems:

  • Content-based filtering: recommendations rely on product properties (e.g., actor or director) but ignore complex user–product relationships; usually implemented with relational databases.
  • Collaborative filtering: recommendations are based on user–item relationships and similarity to other users, accounting for complex connections; typically implemented using a graph database.
  • Hybrid models combine content and collaborative filtering for the best results, despite increased complexity.

The usual components of a product recommendation system are:

  • An e-commerce relational database (RDBMS).
  • A graph database for collaborative PR models and fast complex queries.
  • An ETL system that populates the graph database from the relational source. The PR solution therefore needs an ETL tool or module responsible for:
    • Populating the graph database;
    • Populating specific relational data structures needed for content-based PR models;
    • Populating the e-commerce relational database back with the recommendations data.

Real-time systems offer accuracy but face implementation limits due to:

  • Capacity constraints.
  • Data size limitations.
  • High operating costs.

Why CoraDB

  1. 01

    Technology

    A top-grade graph database.
    Optimized graph algorithms library.
    Unified relational and graph database.

  2. 02

    Performance

    CoraDB handles big data efficiently in both relational and graph engines to ensure fast recommendations.

  3. 03

    Cost advantages

    Affordable pricing.

  4. 04

    Team

    Experienced database team and consultants.

Our solutions

Create a full e-commerce solution from scratch

The assumption is that you have selected your e-commerce application (such as Magento) and what you need on top of it is a high-quality PR system.
Choose CoraDB as the unified backend: use its relational engine for the core e-commerce solution and content-based filtering, and its graph capabilities for collaborative filtering PR models.

Improve your existing e-commerce solution

  • Fully replace your current relational database with CoraDB.
    CoraDB is compatible with standard ANSI SQL databases, so the replacement will go smoothly.
    Use CoraDB graph database capabilities to implement the PR collaborative filtering models.
  • Keep your current relational database and your current content-based PR system, and use CoraDB graph database capabilities to implement PR collaborative filtering models.

The main differentiator between CoraDB and other databases is the multi-model capability built into CoraDB.
Having both relational and graph capabilities in the same unified database engine provides important advantages in design, implementation, maintenance, performance, and overall costs.

Current offering

The usual market design for a hybrid model is the following:

Hybrid recommendation design with a separate relational database, ETL and graph database

CoraDB: simplified, centralized, performant

CoraDB simplifies the hybrid design, boosting performance and easing maintenance by storing all PR data in a single, unpolluted database.

Hybrid recommendation design with CoraDB as the single database

Our services cover all implementation phases:

  1. Analysis

    We will do a complete analysis of your specific requirements and recommend the methods and algorithms that best fit your needs.
    For content-based filtering implementations we will analyze the fit of the most used models, such as vector space models, probabilistic models (Bayes classifiers), decision trees and neural networks.

    -- Content profile: how many units of each category every customer buys.
    SELECT cu.company_name AS customer, c.name AS category,
           SUM(oi.quantity) AS units_bought
    FROM MATCH (cu:customer), (p:product)-[:part_of]->(c:category),
         orders o, order_items oi
    WHERE o.customer_id = cu.id
      AND oi.order_id = o.id
      AND oi.product_id = p.id
    GROUP BY cu.company_name, c.name
    ORDER BY units_bought DESC
    LIMIT 10;
    graph pattern (PGQL)relational tablesOrders and order lines are relational tables; the product categories come from the graph.
    Result10 rows, first 5 shown
    customercategoryunits_bought
    Kelly LtdHoodies & Sweatshirts125
    Young and SonsTees120
    Kelly LtdShorts114
    Young and SonsPerformance Fabrics114
    Mayer, Carroll and OwensShorts100

    For collaborative filtering, the analysis will target the fit of known models such as correlation-based, cosine-based, dimensionality reduction techniques, latent semantic methods, regression, clustering, neural networks, particle filtering and others.

    -- Collaborative filtering: products liked by customers who share
    -- Smith LLC's taste, that Smith LLC does not like yet.
    SELECT p2.name AS product, COUNT(DISTINCT c2.id) AS similar_customers
    FROM MATCH (c1:customer)-[:likes]->(p1:product),
               (c2:customer)-[:likes]->(p1:product),
               (c2:customer)-[:likes]->(p2:product)
    WHERE c1.company_name = 'Smith LLC'
      AND c2.id <> c1.id
      AND p2.id NOT IN (SELECT p.id
                        FROM MATCH (c:customer)-[:likes]->(p:product)
                        WHERE c.company_name = 'Smith LLC')
    GROUP BY p2.name
    ORDER BY similar_customers DESC, product
    LIMIT 10;
    graph pattern (PGQL)Three likes edges in one pattern: Smith LLC, the customers who like the same products, and what else they like.
    Result10 rows, first 5 shown
    productsimilar_customers
    Erika Running Short27
    Balboa Persistence Tee11
    Troy Yoga Short10
    Hollister Backyard Sweatshirt8
    Montana Wind Jacket6

    Content filtering

    • Memory-based: TF-IDF and cosine similarity
    • Model-based: neural networks, Bayesian classifiers

    Collaborative filtering

    • Memory-based: KNN and cosine similarity
    • Model-based: latent factor model
  2. Solution architecture and design

    Based on the analysis results, we will propose the best solution and build the solution architecture and system design, including the design of the data storage (graph database and relational database, as applicable).
    A good solution must address the typical issues of PR systems: cold start, data sparsity, scalability, trust and synonymy.

  3. Development of the ETL module(s)

    For both models, in particular for the collaborative filtering model which requires a graph database back end, we need to select, prepare and load the data needed to run the algorithms (i.e. populate the dedicated graph and relational storage).
    This is achieved by implementing an ETL (Extract-Transform-Load) module or application.

    The ETL solution runs at scheduled periods, or continuously for real-time solutions.
    For example, when you scale to big data (millions of entities), an ETL batch process that calculates in parallel the similarities between the entities in scope (such as users and items) is essential for fast response times.

  4. Product recommendations engine implementation

    In this phase we implement the product recommendations engine, using one or several (hybrid) models:

    • Collaborative module implementation: graph-based algorithms.
    • Content module implementation: relational (or NoSQL) algorithms.
  5. Solution maintenance and support

    Our product team will ensure proper system functionality, periodic updates, solution improvements and evolution.
    As part of the solution, we will also implement tools for specific metrics and efficiency analysis: the quality of a PR system must be measured constantly in order to improve it.

Other scenarios

It is not just users and products that can be used in a recommendation system.
A recommendation system is a more general domain than e-commerce product recommendations: it is any system that provides a recommendation, prediction, opinion, or user-configured list of items that helps the user evaluate items.

The same theory, models, techniques and solutions used for e-commerce PR systems apply in other domains, such as:

  • Data mining
  • Business intelligence
  • Online advertising
  • Content recommenders for social media
  • Web content recommenders
  • Restaurants
  • Online dating
  • Media streaming

Extra ingredient: ML/AI

Recommendation prediction is inexact and depends on factors such as weather, geography and culture, product description keywords, and fashion trends.

All these influence the quality of the recommendations, measured by the increase in sales volume.
To build a more flexible PR system that learns over time and makes connections the usual models miss, Machine Learning and Artificial Intelligence engines are increasingly added to PR systems.

We can put our rich experience in designing and building ML/AI solutions to work to create new recommendation systems or enhance existing ones.

Summary

We have the expertise, skills, experience, and CoraDB technology to build performant recommendation solutions that boost your e-commerce sales and grow your customer base.

Contact us