Graph databases: Neo4j, Amazon Neptune, ArangoDB, SurrealDB
This page is for administrators whose organisation keeps data in a graph or multi-model database and wants that data
in Exponential, or wants a data table of Exponential kept there, and for developers who work on the drivers. From
Exponential 6.0.15 the kernel has one driver per database, expNeo4jDB, expNeptuneDB, expArangoDBDB and
expSurrealDBDB in lib/ezdb/classes/, and the import commands exp:neo4j:import, exp:neptune:import,
exp:arangodb:import and exp:surrealdb:import.
| Level | Neo4j | Amazon Neptune | ArangoDB | SurrealDB |
|---|---|---|---|---|
| (a) The site's database | No | No | No | No (see SurrealQL) |
| (b) A data table connection | Yes | Yes, not tested | Yes | Yes |
| (c) An import source | Yes | Yes, not tested | Yes | Yes |
Amazon Neptune is a service of AWS only; there is no local server of it to test against, so the Neptune driver is
written against Neptune's documented openCypher endpoint and marked not tested (expDataConnections::engines()
reports it as untested). Its Cypher is the same the Neo4j driver runs and is tested.
Contents
- Requirements
- A data table connection
- Importing a graph
- Settings
- How the SQL is answered
- How a graph becomes tables
- What works and what does not
- SurrealQL and a site database
- How it is built
- Tests
Requirements
| What | Where it comes from |
|---|---|
| Neo4j 5 or later (Community or Enterprise) | Its HTTP API on port 7474 (7473 with TLS); Bolt is not needed |
| Amazon Neptune (engine 1.2 or later) | Its openCypher HTTPS endpoint on port 8182, without IAM database authentication or behind a proxy that signs the requests |
| ArangoDB 3.11 or later | Its HTTP API on port 8529 |
| SurrealDB 2 or later | Its HTTP endpoint /sql on port 8000 |
PHP 8.0 or later with curl and sqlite3 | In every PHP build Exponential runs on; no library and no extension of the databases' own |
Why HTTP and not Bolt. Each of the four has an HTTP interface that carries its full query language. Bolt, Neo4j's binary protocol, would need a PHP library; the HTTP API runs the same Cypher in the same transactions.
A data table connection
In the administration, Setup > Data tables > Connections, or in settings/datatable.ini:
[Connection_graph]
Engine=neo4j
Server=graph1.example.com
Port=7474
Database=neo4j
User=exponential
# the name of a secret of the kernel's store (Setup > Secrets), never the password itself
Secret=graph_passwordThe engines are neo4j, neptune, arangodb and surrealdb. The options of a connection are ssl and ssl_ca, and for
SurrealDB namespace. What the database is:
| Engine | Database |
|---|---|
| neo4j | A Neo4j database (Community has the one named neo4j; Enterprise makes others with AutoCreateDatabase) |
| neptune | A name the rows carry (exp_db): a Neptune cluster holds one graph, so several connections can share it |
| arangodb | An ArangoDB database; each table is a collection of the same name |
| surrealdb | A SurrealDB database in the namespace of the option namespace (default exp) |
A persistent class names the connection in its definition ('connection' => 'graph') and reads and writes there; the
data table layer makes its tables, as for any other connection.
Importing a graph
./console exp:neo4j:import --source=graph --list
./console exp:neo4j:import --server=graph1 --database=neo4j --user=reader --secret=env:NEO4J_PASSWORD
./console exp:arangodb:import --source=catalogue --tables=person,knows --prefix=g_ --apply
./console exp:surrealdb:import --server=surreal1 --namespace=shop --database=main --user=root --secret=env:SURREAL_PASSWORD --apply
./console exp:neptune:import --server=https://my-cluster.cluster-xyz.eu-west-1.neptune.amazonaws.com --database=shop --listWithout --apply a command shows the tables it would make and does nothing. --connection=<identifier> imports into a
data table connection instead of the site's database; --mode=create|append|replace, --tables, --prefix, --sample
and --format=json work as for exp:couchbase:import. The exit code is 0 when done (or planned), 1 when a table or row
failed and 2 for wrong options or no connection.
Settings
Each database has a group in site.ini: [Neo4jSettings], [NeptuneSettings], [ArangoDBSettings],
[SurrealDBSettings]. They have the names of [CouchDBSettings]:
| Setting | Default | What it does |
|---|---|---|
TLS, TLSCAFile, TLSVerifyPeer | disabled (Neptune: enabled), empty, enabled | HTTPS to the server; a server written https://host:port turns it on |
ConnectTimeout, RequestTimeout | 5, 60 | Seconds |
AutoCreateDatabase | disabled | Make the database when it is missing (Neo4j: Enterprise only) |
ScanLimit | 100000 | The most rows a statement may read; more is refused, never answered from a part |
BatchSize | 1000 | Rows read or written per request |
JournalLimit | 10000 | Writes of a transaction a rollback can undo |
Namespace (SurrealDB only) | exp | The namespace of the databases |
How the SQL is answered
None of the four answers SQL. The drivers answer it as the CouchDB driver does (see the CouchDB driver page): a
statement reads the rows it needs into an in-memory SQLite database and runs there, so its answer is SQLite's (joins,
GROUP BY, sub-selects, functions); the rows it changes are written back, each with the revision it was read at.
What is sent to the database itself:
| Neo4j, Neptune (Cypher) | ArangoDB (AQL) | SurrealDB (SurrealQL) | |
|---|---|---|---|
| A row | A node labelled ExpDoc and its table | A document of the table's collection | A record table:⟨key⟩ |
| By key | UNWIND $ids ... MATCH (n:ExpDoc) WHERE n._id = i | FILTER d._key IN @keys | SELECT * FROM t:⟨1⟩, t:⟨2⟩ |
col = literal | MATCH (n:ExpDoc:item) WHERE n.name = $c0 | FILTER d[@f0] == @v0 | WHERE name = "pear" |
| A change | MATCH ... WHERE n._rev = $rev SET n = $p | FILTER d.exp_rev == o.rev REPLACE d | UPDATE ... WHERE exp_rev = "..." |
| A new row | OPTIONAL MATCH ... WHERE x IS NULL CREATE (unique constraint on ExpDoc._id) | INSERT (unique _key) | CREATE (a record that exists is an error) |
A change whose revision is no longer the row's is a conflict, and the statement fails rather than overwriting another
writer's change. The tables' definitions are rows of exp_couchdb_schema, the counters of new ids rows of
exp_couchdb_sequence, as in CouchDB. In SurrealDB a column named id is kept as exp_col_id (the record's own id).
How a graph becomes tables
The imports read a graph as it is, not only what the drivers wrote:
| Source | Table | Columns |
|---|---|---|
| A node label (Neo4j, Neptune), a document collection (ArangoDB), a table (SurrealDB) | The name in lower case | doc_id (the node's own id: elementId(), id(), _id, the record id), the properties |
| A relationship type, an edge collection, a relation table | The name, or rel_<name> when a node table has it | doc_id, from_id, to_id (the ids of the two ends), the properties |
The columns and their types come from a sample of each table (--sample, 500 rows): integers, numbers, booleans, text
(memo beyond 255 characters), and lists and maps as JSON text. A table the drivers made keeps its definition: its
columns, types and key. Rows are read in pages of 1000 in the order of their ids.
What works and what does not
| Works | Does not |
|---|---|
Tables made by the data table layer; SELECT of any form SQLite answers; INSERT, UPDATE, DELETE, REPLACE, the upsert of the helpers | A statement that needs more rows than ScanLimit (refused) |
| Revisions: a concurrent change is a conflict, never lost | Transactions of the database: writes are sent at once, a rollback writes back what was there (JournalLimit) |
| Imports of any graph, with nodes and edges as tables | Paging a very large label with SKIP, which slows towards the end |
Neptune: one cluster shared by several databases (exp_db) | Neptune: IAM signing (Signature Version 4); a unique id (Neptune has no constraints); not tested |
| SurrealDB 2 and later | SurrealDB 1.x is not tested |
SurrealQL and a site database
SurrealQL looks like SQL (SELECT ... FROM ... WHERE ... GROUP BY ... ORDER BY ... LIMIT ... START, functions), so it
could be taken further than the other three: a dialect that turns the kernel's SQL into SurrealQL, as the Couchbase
driver does for SQL++, would let one-table statements run in SurrealDB itself. A site database needs more than that:
the kernel joins tables in most of its statements, and SurrealQL has no JOIN (it follows record links instead), no
LEFT JOIN semantics, different NULL/NONE rules and no INSERT ... SELECT. Every join would have to be answered
outside the database, as these drivers do now. The honest estimate is the size of the Couchbase dialect (large) for
data tables answered in SurrealDB, and more for a site. Until then SurrealDB is at levels (b) and (c), like the others.
How it is built
| Class | File | Role |
|---|---|---|
expGraphDB | lib/ezdb/classes/expgraphdb.php | The drivers' base: the CouchDB driver with a store as its transport |
expNeo4jDB, expNeptuneDB, expArangoDBDB, expSurrealDBDB | lib/ezdb/classes/ | One per engine: its settings group, ports, store |
expGraphDocumentStore | lib/ezdb/classes/expgraphdocumentstore.php | Answers the part of CouchDB's HTTP API the CouchDB driver uses |
expCypherStore, expNeo4jStore, expNeptuneStore | lib/ezdb/classes/ | Cypher over Neo4j's tx/commit and Neptune's /openCypher |
expArangoDBStore, expSurrealDBStore | lib/ezdb/classes/ | AQL cursors; SurrealQL over /sql |
expGraphHttp | lib/ezdb/classes/expgraphhttp.php | JSON over HTTP with curl, one kept connection |
expGraphReader | kernel/classes/graph/expgraphreader.php | The imports' reader of a graph |
The schema handler is the CouchDB driver's (expCouchDBSchema, settings/dbschema.ini).
Tests
php vendor/bin/phpunit --testsuite graph # without a server: a store in memory
php vendor/bin/phpunit --testsuite graph-live # against servers named in the environmentgraph-live reads EXP_TEST_NEO4J_HOST, _PORT, _USER, _PASSWORD, _DATABASE, the same for ARANGODB and
SURREALDB (and EXP_TEST_SURREALDB_NAMESPACE); a database without its variables is skipped. The servers can be
the official images:
docker run -d --name neo4j -p 7474:7474 -e NEO4J_AUTH=neo4j/Graph-Test-2026 neo4j:5
docker run -d --name arangodb -p 8529:8529 -e ARANGO_ROOT_PASSWORD=Graph-Test-2026 arangodb:3.12
docker run -d --name surrealdb -p 8000:8000 surrealdb/surrealdb:v2 start --user root --pass Graph-Test-2026 memoryMeasured on 2026-11-28 with PHP 8.5 (podman): Neo4j 5.26.34 Community, ArangoDB 3.12.14 and SurrealDB 4.0.1 pass
graph-live, 15 tests and 189 assertions: tables made by the schema handler, ids from the counter, selects with joins
and aggregates, updates, a changed key, deletes, a rollback, the upsert, a revision conflict, ALTER TABLE,
TRUNCATE, DROP TABLE and the import reader of the driver's tables. On Neo4j Community, whose one database is
neo4j, a test empties the driver's rows instead of dropping the database. Amazon Neptune stays not tested.