EdgeQL is a spiritual successor to SQL designed with a few core principles in mind.
Compatible with modern languages. A jaw-dropping amount of effort has been spent attempting to bridge the gap between the relational paradigm of SQL and high-level type systems of modern programming languages. EdgeDB sidesteps this problem by modeling data in an object-relational way.
Strongly typed. EdgeQL is inextricably tied to EdgeDB's rigorous type system. The type of all expressions is statically inferred by EdgeDB.
Designed for programmers. EdgeQL prioritizes syntax over keywords; It uses { curly braces }
to define scopes/structures and the assignment operator :=
to set values. The result is a query language that looks more like code and less like word soup.
Easy deep querying. EdgeQL takes advantage of the graph-relational nature of EdgeDB schemas. Instead of tables and foreign keys, EdgeDB lets you think in objects, properties, and links. Deep queries that traverse links can be represented cleanly, no JOINs required.
Composable. Unlike SQL, EdgeQL's syntax is readily composable; queries can be cleanly nested to perform subqueries or nested mutations.
All queries below assume the following schema.
abstract type Person {
required property name -> str {
constraint exclusive;
};
}
type Villain extending Person {
link nemesis -> Hero;
}
type Hero extending Person {
property secret_identity -> str;
property number_of_movies -> int64;
multi link villains := .<nemesis[is Villain];
}
type Movie {
required property title -> str;
multi link characters -> Person;
}
It takes almost no time at all to learn the basics of querying in EdgeQL. It combines the intuitiveness of an ORM with the power of raw SQL.
select Hero {
id,
name,
secret_identity
};
[ { "id": "d3b353c6...", "name": "Peter Parker", "secret_identity": "Spider-Man" }, { "id": "af512f80-9d33-11eb-9a94-eb1b8a4d31ed", "name": "Barry Allen", "secret_identity": "The Flash" } ]
EdgeQL makes inserts, updates, upserts, deletes a breeze. Plus, its composable syntax makes nested mutations and upserts a joy to write.
insert Hero {
name := "Sam Wilson",
secret_identity := "The Falcon"
}
{"id": "5f22912a..."}
EdgeQL is no toy language; it supports polymorphic queries, a full slate of built-in convenience functions, JSON casting, and more.
select Hero {
id,
name,
movies := (
select Movie {
id, title
} filter Hero in .characters
)
}
SQL's lack of query composability is one of its biggest drawbacks. EdgeQL was designed with nestable subqueries in mind from the beginning. [ { "id": "90a2457e...", "name": "Tony Stark", "movies": [ { "id": "98ac6cf2...", "title": "The Avengers" } ] }, ... ]
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.