Popular Posts

SQLblog.com - The SQL Server blog spot on the web

Saturday, February 10, 2018

Developing product recommendations on WideWorldImporters using SQL Graph

SQLblog.com - The SQL Server blog spot on the web
Developing product recommendations on WideWorldImporters using SQL Graph

SQL Server has always provided tools to manage hierarchies and relationships, facilitating query execution on hierarchical data, but sometimes relationships can become complex. Think about many-to-many relationships, relational databases don't have a native solution for many-to-many associations. A common approach to realize many-to-many associations is to introduce a table that holds such relationships.

SQL Server 2017, thanks to the Graph Database, can express certain kinds of queries more easily than a relational database by transforming complex relationships into graphs.

The graphs theory is not new in the computer world, the first commercial proposals are dating in the year of 2000 by Neo4J, OrientDB, Oracle Spatial, Graph, etc. Recently, thanks to some of the world's largest internet companies and to the new data processing and analysis requirements, this new class of Object-Oriented Database Management Systems (ODBMS) is receiving a strong impulse.

Today we need to navigate through segments of data quickly and describe how each piece of data is connected to each other by an interconnected logic. A Graph Database is a collection of Nodes and Edges where each node represents an entity and each edge represents a relationship between two nodes with a direction (for example from Node A to Node B).

A few days ago, Microsoft has merged the pull request I have done on the repository Microsoft/sql-server-samples on GitHub. "This repository contains code samples that demonstrate how to use Microsoft's SQL products including SQL Server, Azure SQL Database, and Azure SQL Data Warehouse. Each sample includes a README file that explains how to run and use the sample".

My sample explains what Graph Database is and which scenarios it solves easily, they are available here.

As you can see, the publishment consists of three demos. In the first one, I shown how to create graph objects such as Nodes and Edges. The second demo allows you to do a first look to the T-SQL MATCH clause used to perform some query on Nodes and Edges created in the first demo. In the last demo I shown how to build a recommendation system for sales offers that is able to determine the recommended products based on the product a customer is purchasing.

Have you heard about the Graph Database and want to know more? These examples are a good place to start!

Enjoy the SQL Graph! 

No comments: