9bNine Bits

Social Relation Analysis by Graph Database

Social relation analysis by graph database means storing people as nodes and their connections as edges, then querying those connections directly instead of reconstructing them through table joins. This works because graph databases keep each node linked directly to its neighbors, so following a chain of relationships stays fast even at several hops deep without a fresh index lookup at every step. The same structure underlies friend suggestions, influence scoring, and fraud-ring detection.
Social Relation Analysis by Graph Database

Two weeks ago, we explained ‘Recommender Engine by Graph Database’, and now we will go forth explaining Social Relation Analysis by using Graph Database.

 

What is Social Relation Analysis?

Social Relation data are the data which contains individuals(or organizations) and any relationship between those individuals(or organizations). Social Relation Analysis is an analysis that extracts and analyzes information from Social Relation data(which could be acquired from SNS or organization’s databases), and provides useful reports for individual’s or organization’s tasks. Through the analysis, it can advise person to collaborate with another person, organization to share tasks or information with another organization, buyer to buy another commodities which satisfies his/her taste, organization to develop new product(or service) that would be favored by its customer and etc. Key point of the analysis is to help reading early trends through it, so either individuals or organizations could counteract against fast changing modern society.

Social Relation Analysis in the Real World

During the 2012 US presidential election, the Obama campaign had used Social Relation Analysis to maximize effectiveness of its campaign. Analysts of the Obama campaign collected all relative data(from facebook, twitter, donater information, field survey reports and more) and stored all these data into databases. Afterward, they found relationships between these big chunks of data and made useful result which could help the campaign’s activity dramatically. The Obama campaign used the analysis for sending micro targeted emails to voters, fund-raising events, and public speeches. As the result, not only the campaign could raise more than 690 million US dollars, which is 16.5% more than the previous election, from supporters, but also make Obama as the US president once more.

Social Relation Data and Graph Data Model

Through the 2012 US presidential election case, we can see that Social Relation Analysis is a very powerful tool to learn about the society and make a good use of it for person or organization. However, conventional database systems are not highly suitable for implementing Social Relation data. Since Social Relation data are highly relationship-centralized data, the way of trying to put everything in tabular formats seems not a good way to store and analyze Social Relation data. It will cost anyone, who tries to do Social Relation Analysis, money, time, and human resources. In that manner, Graph data model, which expresses objects and relationships between objects more explicitly, is more suitable to express, store, and analyze Social Relation data. Because Graph data model takes relationships between objects as its first class citizens, Graphs can help you to understand how people are connected, even when you don’t know their initial relationships, and enable you to find useful analysis with an intuitive view.

 

Graph Database for Social Relation

Social Relation data would be more likely to express as Graphs, but putting this data back into tradition databases seems non-sense. Graph databases are developed in the same aspect. They are designed to handle Graphs in their natural formats. By using Graph databases, users can easily handle Graphs and use them as they pleased. In the Graph database world, people and relationships in Social Relation data could be easily stored and processed to find useful analysis between person and organization, person and person, and organization and organization. Both direct and indirect relationships from vertices to vertices in Social Relation data would be analyzed faster and easier through Graph Database. These analyzed results can be used not only politically but also various ways such as market forecast or product development/improvement.

Do graphing with Social Relation Data

Let’s assume that we have a person called “Molly”. Molly is 43 years old woman who has 3 kids and lives in New York. Let’s use a graph database and the PageRank algorithm to analyze her social relation to find what topic she would be interested. To reduce the complexity of analysis, we consider that we have only Facebook data to analyze her. On her Facebook, we find that she clicked more “LIKES” button on environment issues and economy issues than any other topics. Since we found 2 topics that she might be interested, we can use the PageRank algorithm to find the most interesting topic for her. If number of her friends or number of her comments on one topic is greater than the other, then it means it is more likely to get her attention if anyone mentions the topic. For example, if a number of her friends’ or families’ “LIKES” are higher for environment issues, then there is a high chance that she would favor more a politician or a company with environment-friendly policy or product.

 

Common questions

Can I do social relation analysis with plain SQL instead of a graph database?

Yes, for shallow traversals. PostgreSQL's recursive common table expressions can walk a friendship join table a few hops deep. Performance and query readability both degrade as the hop count or the number of relationship types grows, which is when a graph database typically becomes worth the added operational complexity.

What is index-free adjacency and why does it matter for social graphs?

It means each node keeps direct references to its own relationships, so moving from a node to its neighbors does not require scanning an index built across the whole dataset. Social graph queries are mostly chains of these neighbor lookups, so this storage approach keeps multi-hop queries fast as the graph grows.

Is Apache AGE a reasonable choice for a PostgreSQL-based project?

Apache AGE is an open-source PostgreSQL extension that adds Cypher-style graph querying inside an existing Postgres database. It is a reasonable option when a team wants graph-style pattern matching without introducing and operating a separate graph database.

Do I need a separate analytics tool for things like community detection or influence scoring?

Usually yes. Graph databases are built to store relationships and answer pattern-matching queries quickly, while algorithms like PageRank, community detection, or centrality scoring are typically run through dedicated graph algorithm libraries that read the stored graph as input.

Which query language should I learn for graph-based social analysis?

Cypher-style pattern matching, sometimes called openCypher, is the most widely used approach, with Neo4j, Apache AGE, and several other graph databases supporting some version of it. The query-language landscape is still evolving, including the newer GQL standard, so check a specific database's documentation before settling on one. Gremlin, used by Apache TinkerPop-compatible databases, is the main alternative and is more procedural in style.

Sources

  1. Apache AGE Project
  2. PostgreSQL Documentation - Recursive Queries
  3. Apache TinkerPop

About this page

Last reviewed October 30, 2026 by the Nine Bits editors. Read our editorial policy or report an error.