EdgeDB: EdgeQL
website-atgsmhega-edgedb.vercel.app
website-atgsmhega-edgedb.vercel.app
Here's a direct link to the documentation page about EdgeQL: https://www.edgedb.com/docs/edgeql/index.
EdgeQL, the query language of EdgeDB, is a very interesting piece of tech. It's a new, strictly typed query language, that aims to surpass SQL in querying power. Functional in its nature it was designed to be composable and easy to learn. Happy to answer any kind of questions.
EdgeDB itself is almost ready for its 1.0 release, stay tuned. The GH link: https://github.com/edgedb/edgedb/
// Disclaimer: I'm a co-founder & CEO.
> 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.
This is excellent. Allows me to use EdgeDB for the majority of my application, but still treat it as a "plain old Postgres DB" when needed.
When I came across the EdgeDB project, I thought: “damn it’s too good on the paper to be true”. And when I watched the 6th video of “import asyncio” from Łukasz on your YouTube channel, it blew my mind the kind of queries one could achieve, and how flexible was the schema definition with the abstract types.
Although I’ll have to be a bit more patient to push this techno at work, I’m even orienting my personal projects to be a fit for edgedb usage.
Please keep up with the awesome work !
My top features on the roadmap for 1.x:
- LSP
- Query Builders and Schema Reflection
- Fine-grained Data Access Control Rules
Loading arbitrary JSON by introspecting the data, and auto-generating the schema and the necessary DML statements is fairly straightforward too. I have a rough Python proof-of-concept, will need to find time to finish and publish it.
What makes your approach likely to succeed versus all previous attempts to supplant SQL in the last 40 years?
Materialized edges (i.e. what you call "links") are not part of any relational model, it's a part of the graph model. You seem to have implemented a graph database, but possibly without the graph walking capabilities of graph databases.
SELECT Department {
name,
employees := (
SELECT Employee { name, salary }
FILTER Employee.department_name = Department.name
)
}
Links in EdgeQL are merely an abstraction over the fact that most joins in a well-normalized schema are done over primary keys.table1: id, name
table2: table1_id, level
Desired result:
{id, name, level}
SELECT (Table1.id, Table1.name, Table2.level, Table2.table1_id)
FILTER Table1.id = Table2.table1_id;
(This has a somewhat annoying extra output of table1_id, which could be projected away if necessary.)If you want to use edgeql's shapes but still keep the essential join flavor, then something like:
SELECT (Table1 { id, name }, Table2 { level })
FILTER Table1.id = Table2.table1_id;
To make it a little more concrete, you can try this on the tutorial database (https://www.edgedb.com/tutorial) SELECT (Photo {uri}, User {name, email})
FILTER Photo.author.id = User.id;
The tutorial database uses links, and so instead of having an author_id we have author.id, but having an author_id property would work just fine---except that then you'd have to do all the joins manually. SELECT User {
email,
preferences: {
name,
value
}
} FILTER .id = '...'
E.g. in the above example we'd join the underlying User and Preferences tables for you.You can also do cross joins and all other funky stuff.
type Tree {
property value -> str
link parent -> Tree
}
you'd traverse the link as usual: SELECT Tree {
value,
parent: {
value
}
}
FILTER .parent.parent.parent.value = 'foo'
If there's a need to self-join on an arbitrary property, then you could use a `WITH` clause to explicitly bind the two sets: WITH
T1 := Tree,
T2 := Tree
SELECT
T1 {
similarly_valued := (SELECT T2 FILTER T1.value = T2.value)
}``` WITH P := Person SELECT Person { id, full_name, same_last_name := ( SELECT P { id, full_name, } FILTER # same last name P.last_name = Person.last_name AND # not the same person P != Person ), } FILTER EXISTS .same_last_name ```
Apache 2 license: https://github.com/edgedb/edgedb
SELECT in SQL is clunky because it comes before FROM and JOIN. Do you see FROM or JOIN anywhere here? No.
The collections you're selecting from are literally written before the fields you select.
The real WTF for me is this claims to be a relational database and you can't join seemingly.
In any case, the collection you're selecting from is presumably the filtered one, not the original one. Or am I misunderstanding the semantics?
How will you guys make money? As a prospective user, what are the chances of being rethinkdb'd?
There are a few reasons why RethinkDB failed; there's an excellent blog post written by the founder. I think there are many areas where we are quite different:
- We are building on top of Postgres, so we are not investing too much time into the hardest technical problems like creating robust DB storage and query planning/execution engines.
- Instead we focus our time on designing proper high level APIs, the EdgeQL language, migrations, and the DX.
- Yet still, EdgeDB is a relational DB; it's strictly typed and fast. Which is still what the majority of companies want.
Built-in support for that is coming, but it's already possible to run EdgeDB on top of Amazon RDS, for example. Ultimately EdgeDB is built on top of Postgres, so it will support replication and fail-over and many of the existing deployment strategies.
I see that I could use:
edb server --postgres-dsn
But I guess you'll release more docs on using EdgeDB with external instances soon, maybe before 1.0 release.
[1] https://github.com/edgedb/edgedb-docker#official-dockerfile-...
That said, EdgeDB is already stable and solid thanks to the amazing Postgres that we're building it on top of. It's definitely ready now to play with and learn.
Now that I’ve gone there I don’t think I can go back, even if this looks otherwise amazing.
I’ve only been using it for a personal project, but since the fix for the Material UI recipe (which I think was actually related to an npm behavior) I haven’t run into a single bug.
I suspect that’s because it seems like a lot of Blitz is unifying some really good established libraries into a framework. It’s not written from the ground up.
EdgeQL queries are typically way shorter than corresponding SQL equivalents. You can see comparisons and benchmarks here in this blog post: https://www.edgedb.com/blog/edgedb-1-0-alpha-1
Authentication currently is very basic. We plan to have a relatively short release cycle, so in 3-4 months after 1.0 we'll have more robust access control, including read/write policies of individual types and their properties/links.
On the main page. I wish devs stopped giving command line instructions that execute remote bash scripts without any way to look at what's happening under the hood. It's a recipe for disaster, and really, really bad practice.
Is there any plan currently to give back to postgress? If this is already the case, was there anything going upstream from your team?
[0] https://www.edgedb.com/blog/edgedb-a-new-beginning#edgedb.
Anyone care to explain why is that? I thought the query plan should be the same for JOINs and subqueries.
> EdgeDB is a relational database that stores and describes the data as strongly typed objects and relationships between them.
> EdgeDB is built on top of PostgreSQL, inheriting all its core strengths: ACID compliance, performance, and reliability.
select *
or do you always have to specify which keys you want? SELECT User {
...User
}Asking as I have a project ongoing where I don't really have the time to recreate everything in EdgeDB, but wouldn't mind spending a few hours to check how the query language works compared to SQL.
From browsing the current documentation, I can't seem to find anything similar to sqlalchemy's:
meta = MetaData()
meta.reflect(bind=someengine)
users_table = meta.tables['users'] docker run --name edgedb -e EDGEDB_PASSWORD=secret \
-e EDGEDB_POSTGRES_DSN='...' \
-d edgedb/edgedb
RedCrowbar answered this question here [1]Relational database without relational algebra wouldn't be useful, would it? So... uhmm. How do we join? There's no JOIN statement.