EdgeDB is an open-source database designed as a spiritual successor to SQL and the relational paradigm. It aims to solve some hard design problems that make existing databases unnecessarily onerous to use.
Powered by the Postgres query engine under the hood, EdgeDB thinks about schema the same way you do: as objects with properties connected by links. It's like a relational database with an object-oriented data model, or a graph database with strict schema. We call it a graph-relational database.
Install EdgeDB locally with one command:
The core unit of schema in the graph-relational model is the object type—analogous to a table in SQL. Object types contain properties and can be linked to other object types to form a schema graph.
module default {
type Account {
required property username -> str {
constraint exclusive;
};
multi link watchlist -> Content;
}
type Person {
required property name -> str;
link filmography := .<actors[is Content];
}
abstract type Content {
required property title -> str;
multi link actors -> Person {
property character_name -> str;
};
}
type Movie extending Content {
property release_year -> int32;
}
type Show extending Content {
property num_seasons := count(.<show[is Season]);
}
type Season {
required property number -> int32;
required link show -> Show;
}
};
1 2 3 4 5 6 7 8 9 10 11 12type Player { required property username -> str; property clean_username := str_trim(.username); required property level -> int64 { default := 0; constraint min_value(0); } multi link friends -> Person { on target delete allow; }; index on (.username); }
Object types can contain computed properties and links. These "computeds" can return a modified version of a single property, reference multiple properties, or execute an entire subquery. The full power of EdgeQL is at your disposal.
All migrations are generated and tracked by the database. You can interactively sanity-check each migration step with the CLI-based migration workflow.
1 2 3 4 5 6 7 8module default { type User { required property username -> str; } }
1 2 3 4 5 6 7 8CREATE MIGRATION m1kdtk6ze2irotrxzscsr5hmt55zxv... { ALTER TYPE default::User { CREATE REQUIRED PROPERTY email -> std::str { SET REQUIRED USING ('example@example.com'); }; }; };
$
EdgeQL solves the object-relational impedance mismatch by returning a structured result object, not a list of rows—eliminating the need for a third-party ORM to denormalize the results.
EdgeQL queries are fully composable, making things like subqueries and nested inserts a breeze.
SQL was designed with 1970s businessmen in mind, and it shows. EdgeQL uses syntax that's familiar to developers to represent selection sets, scope, structure, and property assignment.
# EdgeQL
select Movie {
title,
actors: {
name
},
};
# SQL
SELECT
title,
Actors.name AS actor_name
FROM Movie
LEFT JOIN Movie_Actors ON
Movie.id = Movie_Actors.movie_id
LEFT JOIN Person AS Actors ON
Movie_Actors.person_id = Person.id
It’s not an ORM; all the “object relational mapping” happens inside EdgeDB. Instead, it’s a query builder that’s auto-generated from your schema, can represent arbitrarily complex EdgeQL queries, and statically infers the type of the query result. Bye, bye, ORMs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import e, {createClient} from "./dbschema/edgeql-js";
const client = createClient();
const query = e.select(e.Movie, (movie) => ({
title: true,
actors: (actor) => ({
name: true,
uppercase_name: e.str_upper(actor.name),
order_by: actor.name
}),
num_actors: e.count(movie.actors),
filter: e.op(movie.title, 'ilike', '%avengers%')
}));
// fully typed results!
const result = await query.run(client);
result.actors[0].name;
$
npm install edgedb
$
pip install edgedb
$
go get github.com/edgedb/edgedb-go
import * as edgedb from "https://deno.land/x/edgedb/mod.ts";
$
cargo add edgedb-tokio
$
dart pub add edgedb
$
dotnet add package EdgeDB.Net.Driver
add :edgedb to mix.exs
Use our all-encompassing CLI to spin up new instances, create and apply migrations, introspect schema, and scaffold EdgeDB-backed applications. Install it with one command.
$
curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
EdgeDB CLI installed.
$
edgedb project init
Do you want to initialize a new project? [Y/n] > Y
$
edgedb
edgedb> select 2 + 2;
While we develop a hosted version—more on that later—you can host EdgeDB with your cloud of choice or self-host with our official Docker image.
We're building an EdgeDB hosting platform that’s full-managed, auto-scaling, serverless-friendly, and tightly integrated with our CLI. Drop your email to hear when it's ready.
EdgeDB's binary protocol is designed to have minimal latency possible, fast data marshalling, and to survive network errors.
EdgeDB is analagous to "LLVM for data", in that it compiles its high-level schema and queries to low-level tables and optimized SQL. The result is great performance without sacrificing usability or functionality.
EdgeDB uses PostgreSQL as its data storage and query execution engine, benefitting from its exceptional reliability.
Convenience usually comes at the price of performance, but not this time. EdgeQL is compiled into Postgres queries that go head-to-head with the best handwritten SQL.
EdgeDB is 100% Open Source and is distributed under Apache 2.0 license, including the database core, the client libraries, the CLI, and many other upcoming libraries and services.
Check us out on GitHub!EdgeDB goes well beyond a typical feature set of a database. Features that are traditionally pushed to clients to deal with (HTTP API, GraphQL, observability) are implemented right in the core.
EdgeDB server utilizes non-blocking IO to make client connections cheap and scalable, solving the connection overload problem that's increasingly prevalent in an auto-scaling, serverless deployments. The underlying PostgreSQL connection pool will be automatically scaled as needed.
Normally convenience comes at the price of performance, but not this time. Under the hood, each EdgeQL query is compiled into a single, optimized Postgres query that goes to-head with the best handwritten SQL.
Install EdgeDB, create a simple schema, and write your first queries in under 5 minutes.
The quickest way to learn the key concepts of EdgeDB without installation, right in your browser.
An easy to follow book about using EdgeDB for an imaginary game based on the setting in Bram Stoker's 1897 book Dracula.
An in-depth look at everything there is to know about EdgeDB: data types, query language, schema and database setup, etc.
EdgeDB is a new database with its own query language, type system, and set of tools and conventions.
That said, EdgeDB is built on top of Postgres. This lets us design a better abstraction for databases while taking advantage of the incredible work done by the Postgres community over the past 35 (!) years. Internally, all EdgeQL queries are compiled into an equivalent Postgres query. You can run EdgeDB as a query engine on top of an externally hosted Postgres instance or let EdgeDB manage Postgres for you under the hood.
No. Like every database throughout history, EdgeDB introduces a layer of abstraction on top of more primitive mechanisms performing data access and manipulation. In the case of most databases, these mechanisms are often low-level key-value stores (for example, WiredTiger in MongoDB, InnoDB in MySQL, or RocksDB in CockroachDB). EdgeDB takes this concept one level further: it treats PostgreSQL as a lower-level storage engine and introduces better schema and query abstractions on top.
In contrast, ORMs are libraries that provide a high-level way to query and manipulate data in your database. Typically an ORM :
EdgeDB has none of these properties. You query and manipulate data with a full-featured query language (EdgeQL) that is designed to match or surpass the power of SQL (though certain advanced features are still under development, see the Roadmap for details). It's language agnostic: you can interact with your database with any programming language you like. And it was designed from the start as a new abstraction on top of Postgres specifically.
That last part is important. It lets EdgeDB take full advantage of the power of Postgres, whereas ORMs cannot; their capabilities are limited to features shared by all the databases they support.
The graph-relational model is a new conceptual model for representing data. Under this model, data is represented as strongly-typed objects that contain set-valued scalar properties and links to other objects.
It takes the relational model and extends it in some key ways.
readonly uuid
property called id
.For a more in-depth discussion of the graph-relational model, refer to this blog post.
There are a lot! Scroll down to the "Showcase" below for a bunch of examples. As a rough structure, we consider the main innovations to be three-fold:
The EdgeQL query language: a full redesign of SQL that has been sorely needed for decades. This includes support for GraphQL-style selection sets, easily nestable subqueries (including inserts and updates), a new link
concept that abstracts away JOINs and foreign keys, edge properties, and a typesafe NULL-free type system grounded in set theory.
Declarative schema. The EdgeDB spec includes a schema definition language (simply called the EdgeDB SDL) that lets you define your schema declaratively and succinctly, including advanced features like abstract types, computed fields, unions, custom scalars, and JSON support.
First-party migrations. Migrations have been a pain point for developers since the introduction of SQL. Hundreds of libraries across dozens of language ecosystems have tried to solve the problem of SQL migrations. EdgeDB ships with a first-party interactive migration tool baked directly into the `edgedb` command-line tool.
But there are a hundred cool and nifty ways we’ve upgraded the developer experience of creating, querying, and managing databases. Jump into the docs to understand EdgeDB in all its glory.