ArgoDB

This page explains the property graph model behind Neo4j and similar systems, shows how queries execute, compares Cypher with ArangoDB's AQL, and lists when a graph database is worth adopting.

1. ArgoDB

ArgoDB is a specialized distributed database optimized for complex, large-scale graph data. It is designed to handle high-performance graph processing workloads, providing efficient querying and analysis of relationships within data, such as social networks, fraud detection, and recommendation systems.


Key Features:

ArgoDB excels in scaling effectively and delivering rapid analysis for graph-related use cases, making it distinct from other graph databases.

2. ArgoDB (or ArangoDB) vs Neo4j Code Example

While ArgoDB and Neo4j are different databases, the code example below is based on Neo4j, a popular graph database. If you're referring to ArangoDB, which is a multi-model database (graph, document, key-value), the syntax would be different, but the concept of handling nodes and relationships remains similar.


Python Code Example (Neo4j)


from neo4j import GraphDatabase

class ArgoDBExample:

    def __init__(self, uri, user, password):
        self.driver = GraphDatabase.driver(uri, auth=(user, password))

    def close(self):
        self.driver.close()

    def create_node(self, name):
        with self.driver.session() as session:
            session.write_transaction(self._create_node, name)

    @staticmethod
    def _create_node(tx, name):
        query = "CREATE (n:Person {name: $name})"
        tx.run(query, name=name)

    def create_relationship(self, person1, person2, relation):
        with self.driver.session() as session:
            session.write_transaction(self._create_relationship, person1, person2, relation)

    @staticmethod
    def _create_relationship(tx, person1, person2, relation):
        query = """
        MATCH (a:Person {name: $person1}), (b:Person {name: $person2})
        CREATE (a)-[:KNOWS {relation: $relation}]->(b)
        """
        tx.run(query, person1=person1, person2=person2, relation=relation)

    def find_friends(self, name):
        with self.driver.session() as session:
            result = session.read_transaction(self._find_friends, name)
            for record in result:
                print(f"{name} knows {record['friend']}")

    @staticmethod
    def _find_friends(tx, name):
        query = """
        MATCH (a:Person)-[:KNOWS]->(friend)
        WHERE a.name = $name
        RETURN friend.name AS friend
        """
        return tx.run(query, name=name)

# Example usage
db = ArgoDBExample("bolt://localhost:7687", "neo4j", "password")

# Create nodes
db.create_node("Alice")
db.create_node("Bob")

# Create relationships
db.create_relationship("Alice", "Bob", "Friends")

# Find friends of Alice
db.find_friends("Alice")

db.close()

  

Explanation

This example shows how to work with Neo4j, a graph database, using Python. Here's a breakdown of the code:

If you're using ArangoDB or ArgoDB, you would adapt the queries and the way you handle data according to their APIs or query languages.

3. The property graph model

The Property Graph Model (:Person) name: Alice (:Person) name: Bob (:Company) name: Acme (:Person) name: Carol KNOWS WORKS_AT KNOWS Relationships are stored as first-class records, so traversals follow pointers instead of joins.

Most graph databases, including Neo4j, implement the labelled property graph. Nodes carry one or more labels (Person, Company) and key/value properties. Relationships are directed, have exactly one type (KNOWS, WORKS_AT), and can carry properties of their own, such as a start date. Because relationships are stored records rather than rows reconstructed at query time with joins, the cost of following one hop depends on the local degree of a node, not on the total size of the data. That is the property that makes multi-hop questions such as “friends of friends who work at the same company” practical at scale.

The names in this area are easy to confuse. Neo4j is a native property-graph database queried with Cypher. ArangoDB is a multi-model database that stores documents, key/value pairs and graphs in one engine and is queried with AQL. ArgoDB is a distributed analytical database from Transwarp. Check vendor documentation for the specific product before relying on feature claims.

4. How a query runs

Query Path in Neo4j App driver Bolt protocol Cypher planner cost-based Traversal index-free adjacency Page cache graph store Result records An index (e.g. on :Person(name)) finds the start node; from there each hop is a pointer chase.

A client connects over the Bolt binary protocol, sends a parameterised Cypher statement, and receives a stream of records. The planner chooses a start point, usually an index seek on a label and property, then expands relationships hop by hop. Neo4j's store layout keeps each node's relationship chain directly reachable from the node record (“index-free adjacency”), and the page cache keeps hot parts of the store in memory. Writes are ACID transactions; clustered deployments replicate them with a Raft-based protocol to a set of primary servers, with secondaries for read scaling.

5. Example queries

// Cypher (Neo4j): friends of friends Alice does not already know
MATCH (a:Person {name: 'Alice'})-[:KNOWS]->()-[:KNOWS]->(fof)
WHERE fof <> a AND NOT (a)-[:KNOWS]->(fof)
RETURN DISTINCT fof.name;

// AQL (ArangoDB): the same two-hop traversal over an edge collection
FOR v, e, p IN 2..2 OUTBOUND 'persons/alice' knows
  FILTER v._key != 'alice'
  RETURN DISTINCT v.name

The Python example above uses the official Neo4j driver. In driver version 5 the read_transaction and write_transaction methods are deprecated in favour of execute_read and execute_write, which take the same transaction function and retry it automatically on transient cluster errors.

6. When to use a graph database

OptionStrengthChoose when
Neo4jMature Cypher, tooling, graph algorithms libraryRelationship-heavy OLTP queries, fraud rings, knowledge graphs
ArangoDBDocuments and graphs in one engineMixed document and graph access with one query language
Amazon NeptuneManaged, Gremlin / openCypher / SPARQLAWS-native teams wanting no server operations
Relational DB with recursive CTEsOne system, strong toolingShallow hierarchies, few hops

A graph database pays off when queries traverse variable or deep paths. If most queries are aggregations over large tables, a columnar warehouse is faster; if relationships are shallow and fixed, a relational schema is simpler to operate.

7. Pitfalls

See JanusGraph and Dgraph for distributed alternatives, and Graph Algorithms for the BFS, DFS and Dijkstra traversals these engines run internally.