Top Related Projects
A library that provides an embeddable, persistent key-value store for fast storage.
TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.
OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
Graphs for Everyone
Quick Overview
Dgraph is a distributed graph database written in Go, designed to provide scalable and fast graph operations with low latency. It offers a simple and flexible approach to storing and querying interconnected data, making it suitable for various applications, including social networks, recommendation systems, and knowledge graphs.
Pros
- High performance and scalability for large-scale graph data
- Native support for GraphQL-like query language (GraphQL+-) and HTTP/gRPC APIs
- Built-in support for ACID transactions and horizontal sharding
- Active development and community support
Cons
- Steeper learning curve compared to traditional relational databases
- Limited ecosystem of third-party tools and integrations
- Potential complexity in managing distributed deployments
- Some advanced features are only available in the enterprise version
Code Examples
- Creating a schema:
type Person {
name: string @index(exact) .
age: int .
friend: [uid] @reverse .
}
- Mutating data:
{
set {
_:alice <name> "Alice" .
_:alice <age> "30" .
_:bob <name> "Bob" .
_:bob <age> "32" .
_:alice <friend> _:bob .
}
}
- Querying data:
{
people(func: has(name)) {
name
age
friend {
name
}
}
}
Getting Started
- Install Dgraph:
curl https://get.dgraph.io -sSf | bash
- Start Dgraph:
dgraph zero
dgraph alpha
- Use the Ratel UI or send HTTP requests to interact with Dgraph:
curl -H "Content-Type: application/rdf" localhost:8080/mutate?commitNow=true -XPOST -d $'
{
set {
_:alice <name> "Alice" .
_:alice <age> "30" .
}
}'
- Query data:
curl -H "Content-Type: application/graphql+-" localhost:8080/query -XPOST -d '{
people(func: has(name)) {
name
age
}
}'
Competitor Comparisons
A library that provides an embeddable, persistent key-value store for fast storage.
Pros of RocksDB
- Highly optimized for fast storage, especially SSDs
- Flexible and customizable with various compression and caching options
- Widely adopted and battle-tested in production environments
Cons of RocksDB
- Lower-level storage engine, requiring more integration work
- Less suitable for distributed systems out of the box
- Steeper learning curve for developers new to key-value stores
Code Comparison
RocksDB (C++):
#include <rocksdb/db.h>
rocksdb::DB* db;
rocksdb::Options options;
options.create_if_missing = true;
rocksdb::Status status = rocksdb::DB::Open(options, "/path/to/db", &db);
Dgraph (Go):
import "github.com/dgraph-io/dgraph/client"
c := client.NewDgraphClient(client.DefaultOptions)
err := c.Alter(context.Background(), &api.Operation{
Schema: `name: string @index(exact) .`,
})
Key Differences
- RocksDB is a low-level storage engine, while Dgraph is a distributed graph database
- Dgraph provides a higher-level abstraction with built-in graph querying capabilities
- RocksDB offers more fine-grained control over storage optimizations
- Dgraph includes features like ACID transactions and horizontal scaling out of the box
TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
Pros of TiDB
- Supports SQL, making it easier for users familiar with relational databases
- Designed for horizontal scalability and high availability
- Offers strong consistency and ACID compliance
Cons of TiDB
- Higher complexity in setup and maintenance compared to Dgraph
- May have slower performance for graph-based queries
- Requires more resources for optimal performance
Code Comparison
TiDB (SQL-based query):
SELECT * FROM users
JOIN orders ON users.id = orders.user_id
WHERE orders.total > 100;
Dgraph (GraphQL+-based query):
{
users(func: has(order)) @filter(gt(order.total, 100)) {
name
order {
id
total
}
}
}
Both repositories are open-source distributed database systems, but they serve different purposes. TiDB is a NewSQL database that combines features of traditional relational databases with the scalability of NoSQL systems. Dgraph, on the other hand, is a native GraphQL database designed for efficient graph-based queries.
TiDB is better suited for applications requiring SQL compatibility and strong consistency, while Dgraph excels in scenarios involving complex relationships and graph-based data models. The choice between the two depends on the specific requirements of the project, such as query patterns, scalability needs, and the development team's expertise.
CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
Pros of CockroachDB
- Stronger SQL compliance and support for complex queries
- Better horizontal scalability and distributed architecture
- More mature ecosystem with extensive documentation and tooling
Cons of CockroachDB
- Higher resource consumption and complexity
- Steeper learning curve for newcomers
- Less flexible schema design compared to Dgraph's graph model
Code Comparison
Dgraph query example:
{
user(func: eq(name, "Alice")) {
name
friends {
name
}
}
}
CockroachDB query example:
SELECT u.name, f.name AS friend_name
FROM users u
JOIN friendships fr ON u.id = fr.user_id
JOIN users f ON fr.friend_id = f.id
WHERE u.name = 'Alice';
Key Differences
- Dgraph is a graph database, while CockroachDB is a distributed SQL database
- Dgraph uses GraphQL-like query language, CockroachDB uses standard SQL
- Dgraph excels in handling complex relationships, CockroachDB in distributed ACID transactions
- CockroachDB offers stronger consistency guarantees across distributed setups
- Dgraph provides faster traversal of deeply nested relationships
Both databases have their strengths and are suited for different use cases. Choose based on your specific requirements, data model, and scalability needs.
🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.
Pros of ArangoDB
- Multi-model database supporting key/value, document, and graph data models
- Flexible query language (AQL) for complex data operations
- Built-in support for full-text search and geospatial queries
Cons of ArangoDB
- Higher memory consumption compared to Dgraph
- Steeper learning curve due to its multi-model nature
- Less optimized for large-scale distributed graph processing
Code Comparison
ArangoDB query example:
FOR user IN users
FILTER user.age > 30
RETURN user.name
Dgraph query example:
{
users(func: gt(age, 30)) {
name
}
}
Both databases offer query languages tailored to their respective data models. ArangoDB's AQL provides a SQL-like syntax for querying multiple data models, while Dgraph's GraphQL+-based language is optimized for graph queries.
ArangoDB excels in versatility, supporting multiple data models within a single database. Dgraph, on the other hand, is purpose-built for graph data, offering better performance and scalability for large-scale graph processing tasks.
Choose ArangoDB for projects requiring flexibility across different data models, and Dgraph for applications focused primarily on graph data and requiring high scalability.
OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
Pros of OrientDB
- Multi-model database supporting graph, document, key/value, and object models
- SQL-like query language (OrientDB SQL) for easier adoption by SQL developers
- Built-in support for multi-master replication and sharding
Cons of OrientDB
- Less optimized for large-scale distributed graph processing compared to Dgraph
- Steeper learning curve due to multiple data models and complex querying options
- Smaller community and ecosystem compared to Dgraph
Code Comparison
OrientDB query example:
SELECT FROM Person
WHERE name = 'John'
AND out('Friend').name CONTAINS 'Alice'
Dgraph query example:
{
person(func: eq(name, "John")) @filter(has(friend)) {
name
friend @filter(eq(name, "Alice")) {
name
}
}
}
Both databases offer powerful querying capabilities, but OrientDB's SQL-like syntax may be more familiar to developers with SQL backgrounds, while Dgraph's GraphQL-like syntax is more aligned with modern graph query languages.
OrientDB provides flexibility with its multi-model approach, making it suitable for various use cases. Dgraph, on the other hand, focuses on distributed graph processing, offering better performance for large-scale graph operations. The choice between the two depends on specific project requirements and the development team's expertise.
Graphs for Everyone
Pros of Neo4j
- Mature and widely adopted graph database with a large community
- Powerful Cypher query language for complex graph traversals
- Extensive documentation and enterprise support options
Cons of Neo4j
- Can be resource-intensive for large-scale deployments
- Scaling horizontally can be challenging compared to Dgraph's native sharding
- Steeper learning curve for developers new to graph databases
Code Comparison
Neo4j (Cypher query):
MATCH (p:Person)-[:KNOWS]->(f:Person)
WHERE p.name = "Alice"
RETURN f.name
Dgraph (GraphQL+-):
{
person(func: eq(name, "Alice")) {
name
knows {
name
}
}
}
Both examples show a simple query to find friends of a person named "Alice". Neo4j uses the Cypher query language, which is specific to graph databases, while Dgraph uses a GraphQL-like syntax that may be more familiar to developers with experience in modern API development.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
The Only Native GraphQL Database With A Graph Backend.
Dgraph is a horizontally scalable and distributed GraphQL database with a graph backend. It provides ACID transactions, consistent replication, and linearizable reads. It's built from the ground up to perform a rich set of queries. Being a native GraphQL database, it tightly controls how the data is arranged on disk to optimize for query performance and throughput, reducing disk seeks and network calls in a cluster.
Dgraph's goal is to provide Google production-level scale and throughput, with low enough latency to serve real-time user queries over terabytes of structured data. Dgraph supports GraphQL query syntax, and responds in JSON and Protocol Buffers over GRPC and HTTP. Dgraph is written using the Go Programming Language.
Status
Dgraph is at version v24.0.2 and is production-ready. Apart from the vast open source community, it is being used in production at multiple Fortune 500 companies, and by Intuit Katlas and VMware Purser. A hosted version of Dgraph is available at https://cloud.dgraph.io.
Supported Platforms
Dgraph officially supports the Linux/amd64 architecture. Support for Linux/arm64 is in development. In order to take advantage of memory performance gains and other architecture-specific advancements in Linux, we dropped official support Mac and Windows in 2021, see this blog post for more information. You can still build and use Dgraph on other platforms (for live or bulk loading for instance), but support for platforms other than Linux/amd64 is not available.
Running Dgraph in a Docker environment is the recommended testing and deployment method.
Install with Docker
If you're using Docker, you can use the official Dgraph image.
docker pull dgraph/dgraph:latest
For more information on a variety Docker deployment methods including Docker Compose and Kubernetes, see the docs.
Run a Quick Standalone Cluster
docker run -it -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph dgraph/standalone:latest
Install from Source
If you want to install from source, install Go 1.19+ or later and the following dependencies:
Ubuntu
sudo apt-get update
sudo apt-get install build-essential
Build and Install
Then clone the Dgraph repository and use make install
to install the Dgraph binary in the directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set.
git clone https://github.com/dgraph-io/dgraph.git
cd dgraph
make install
Get Started
To get started with Dgraph, follow:
- Installation to queries in 3 steps via dgraph.io/docs/.
- A longer interactive tutorial via dgraph.io/tour/.
- Tutorial and presentation videos on YouTube channel.
Is Dgraph the right choice for me?
- Do you have more than 10 SQL tables connected via foreign keys?
- Do you have sparse data, which doesn't elegantly fit into SQL tables?
- Do you want a simple and flexible schema, which is readable and maintainable over time?
- Do you care about speed and performance at scale?
If the answers to the above are YES, then Dgraph would be a great fit for your application. Dgraph provides NoSQL like scalability while providing SQL like transactions and the ability to select, filter, and aggregate data points. It combines that with distributed joins, traversals, and graph operations, which makes it easy to build applications with it.
Dgraph compared to other graph DBs
Features | Dgraph | Neo4j | Janus Graph |
---|---|---|---|
Architecture | Sharded and Distributed | Single server (+ replicas in enterprise) | Layer on top of other distributed DBs |
Replication | Consistent | None in community edition (only available in enterprise) | Via underlying DB |
Data movement for shard rebalancing | Automatic | Not applicable (all data lies on each server) | Via underlying DB |
Language | GraphQL inspired | Cypher, Gremlin | Gremlin |
Protocols | Grpc / HTTP + JSON / RDF | Bolt + Cypher | Websocket / HTTP |
Transactions | Distributed ACID transactions | Single server ACID transactions | Not typically ACID |
Full-Text Search | Native support | Native support | Via External Indexing System |
Regular Expressions | Native support | Native support | Via External Indexing System |
Geo Search | Native support | External support only | Via External Indexing System |
License | Apache 2.0 | GPL v3 | Apache 2.0 |
Users
- Dgraph official documentation is present at dgraph.io/docs/.
- For feature requests or questions, visit https://discuss.dgraph.io.
- Check out the demo at dgraph.io and the visualization at play.dgraph.io.
- Please see releases tab to find the latest release and corresponding release notes.
- See the Roadmap for a list of working and planned features.
- Read about the latest updates from the Dgraph team on our blog.
- Watch tech talks on our YouTube channel.
Developers
- See a list of issues that we need help with.
- Please see Contributing to Dgraph for guidelines on contributions.
Client Libraries
The Dgraph team maintains several officially supported client libraries. There are also libraries contributed by the community unofficial client libraries.
Contact
- Please use discuss.dgraph.io for documentation, questions, feature requests and discussions.
- Please use discuss.dgraph.io for filing bugs or feature requests.
- Follow us on Twitter @dgraphlabs.
Top Related Projects
A library that provides an embeddable, persistent key-value store for fast storage.
TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.
OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
Graphs for Everyone
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot