Graph analysis engine
AnalyticDB for PostgreSQL integrates a graph analysis engine as an extension that supports efficient Cypher queries and operations on graph data. Graph analysis engines excel at processing highly interconnected datasets in scenarios such as social networks, fraud detection, recommendation engines, knowledge graphs, and network/IT O&M.
What is a graph?
The basic components of a graph are nodes and edges. Nodes represent objects or entities, and edges describe the relationships between nodes.
In the preceding figure, nodes represent entities such as Product A, Company A, and employees. Edges represent relationships between these entities, such as employment, friendship, and R&D involvement. Properties can be attached to nodes and edges to enrich the data. For example, employee numbers on nodes or employment start times on edges. A graph with properties is called a property graph.
Graphs describe entities and relationships intuitively. Graph models support multiple node types, edge types, and properties, making them well-suited for highly interconnected data scenarios.
Graph analysis engine elements
|
Element |
Description |
|
Graph |
A data structure of nodes (entities) and edges (relationships). For example, in a social network, each person is a node, and connections such as friends, family, and colleagues are edges. |
|
Node |
Core elements that represent entities in a database. Each node can carry labels to store entity information. For example, in a social network, nodes represent users, companies, or organizations, with labels such as age, name, or address. |
|
Edge |
Edges connect nodes and describe relationship characteristics through labels such as weight and direction. In a social network, edges represent relationships like following, friendship, or fans. Weight reflects relationship strength (for example, interaction frequency), and direction indicates the flow of a relationship (for example, user A follows user B). |
|
Label |
A type of property used to categorize and identify nodes or edges, providing semantic context and improving query efficiency. For example, node labels such as Person or Company distinguish entity types, while edge labels such as Knows or Works In describe relationship types. |
|
Property graph |
If the nodes or edges in a graph contain labels, this type of graph structure is called a property graph. |
|
Pattern |
In Cypher, queries revolve around patterns that match specific graph structures. When matching structures are found or created, the results can be used for further data processing or analysis. |
Advantages
Compared with the table schema of traditional relational databases, the graph structure of AnalyticDB for PostgreSQL offers more flexible data modeling. It organizes data as nodes and edges with node-centric access, and supports CRUD operations on graph data.
For example, a node can quickly access all adjacent nodes through its outgoing edges, intuitively expressing complex entity relationships and efficiently handling highly interconnected data.
|
Difference |
Graph analysis engine |
Relational database |
|
Focus |
Focuses on data entities and their relationships. |
Focuses on data storage classification with predefined table schemas. |
|
Flexibility |
High flexibility. To accommodate significant data changes, add new nodes, edges, and properties with corresponding types. |
Low flexibility. Significant data changes require table schema adjustments or new tables, incurring high modification costs. |
|
Intuitiveness and complexity |
Graphs express real-world relationships directly and naturally. Queries traverse node-edge topologies to locate data quickly, simplifying complex relationship processing. |
Requires entity and relationship tables with complex mappings, demanding higher abstract thinking. |