SQL Graph queries and improvements
A graph database consists of nodes and edges. The nodes represent entities in your graph, such as people or organizations, and edges represent the relationship between two entities. The graph databases are optimized for implementing hierarchies and many-to-many relationships, and for analyzing interconnected data and relationships. This is difficult to implement in a relational database.
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 in Figure 11.12 that allows users to do this:
Note
To find out more about graphs, refer to https://docs.microsoft.com/sql/relational-databases/graphs/sql-graph-overview?view=sql-server-ver15.
Figure 11.12: Social media model for following users
In Figure 11.12, the circles represent nodes and the lines...