SQL Graph Queries and Improvements
A graph database consists of nodes and edges. The nodes are the vertices, and edges represent the relationship between the two nodes. The graph databases are optimized for implementing hierarchies and many-to-many relationships, and to analyze interconnected data and relationships. This is difficult to implement in a relational database.
The graph database functionalities were introduced in SQL Server 2017.
Let's look at modeling a very popular use case for a graph database: a social media application. A social media application allows users to follow, like, post, comment, and tag other users. Let's look at a simple model that allows users to do this:
Figure 10.12: Social media model for following users
In the preceding diagram, the circles represent nodes and the lines represent edges or relationships. The relationship is "follows". The graph tells us that Amy follows Hudson, Hudson follows Kayla, Kayla follows Amy, Amy...