37

Graphs in SQL

The terminology in graph theory pretty much explains itself; the concept of a bunch of lines connecting dots seems simple enough. But graph theory is surprisingly powerful and rich in mathematical complexity. You might want to read some of the books suggested in the last section of this chapter, if you never had a course in it before.

Graphs are important because they are a general way to represent many different types of data and their relationships. A few examples among many are:

• Social networks

• Friend of a friend

• Degree of separation

• Traffic routing

Here is a quick review of terms, though you will find other authors have different ones for the same concepts.

A graph is a data structure made up of nodes connected ...

Get Joe Celko's SQL for Smarties, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.