The release of the relational-graph database EdgeDB 4.0

The release of database system EdgeDB 4.0 has been announced, implementing a relational-graph data model and EdgeQL query language optimized for handling complex hierarchical data. The code is written in Python and Rust (parser and performance-critical parts) and is distributed under the Apache 2.0 license. The project is developed as an extension on top of PostgreSQL. Client libraries are available for Python, Go, Rust, .NET, Elixir, and TypeScript/Javascript. A command-line toolkit is provided for managing the database system and for interactive query execution (REPL).

Instead of a table-based data model, EdgeDB employs a declarative system based on object types. Instead of foreign keys to define relationships between types, it uses links (one object can be used as a property of another object).

type Person { required name: str; } type Movie { required title: str; multi actors: Person; }

Indexes can be used to speed up query processing. Features such as strict property typing, property value constraints, computed properties, and stored procedures are also supported. Among the features of EdgeDB's object storage schema, which somewhat resembles ORM, are the ability to mix schemas, link properties from different objects, and integrated JSON support.

Built-in tools are provided for schema migration — after changing the schema defined in a separate esdl file, simply execute the command 'edgedb migration create' and the database will analyze the differences in the schema and interactively generate a script for migrating to the new schema. The history of schema changes is automatically tracked.

For forming queries, both GraphQL and EdgeDB's own query language, which is an adaptation of SQL for hierarchical data, are supported. Instead of lists, query results are presented in a structured form, and instead of subqueries and JOIN operations, it allows specifying one EdgeQL query as an expression within another query. Transactions and loops are supported.

select Movie { title, actors: { name } } filter .title = 'The Matrix' insert Movie { title := 'The Matrix Resurrections', actors := ( select Person filter .name in { 'Keanu Reeves', 'Carrie-Anne Moss', 'Laurence Fishburne' } ) }

In the new version:

  • Full-text search support has been added, implemented through a plug-in module fts. To turn any object into a searchable document, the fts::index should be used, and the function fts::search() is provided to search for a specific phrase among indexed documents. Results are returned as tuples containing the found object and its search weight. For example: type Item { required available: bool { default := false; }; required name: str; required description: str; index fts::index on ( fts::with_options( .name, language := fts::Language.eng ) ); } with res := ( select fts::search(Item, 'candy corn', language := 'eng') ) select res.object {name, score := res.score} order by res.score desc;
  • A new data type 'multirange' has been added, defining one or more ranges of values to represent disjoint intervals. Normalization of overlapping areas within specified ranges is performed automatically. All previously available functions and operators for handling ranges can work with the 'multirange' type. select multirange([range(8, 10)]) + range(1, 5) — range(3, 4);
  • Support for authentication has been added and is enabled by default to restrict access to GraphQL and EdgeQL over HTTP.
  • To launch an authentication service functioning separately from the database instance, the 'auth' extension has been added, supporting OAuth or login via email and password.
  • The pgcrypto extension has been added, providing functions hmac, gen_salt, and crypt for hashing and encryption. select ext::pgcrypto::digest('encrypt this', 'sha1');
  • The pg_trgm extension has been added with functions for determining string similarity.
  • Optimizations have been made that increased performance. Memory consumption has been reduced by server 40%. The parser code for EdgeQL has been rewritten in Rust.
  • The EdgeQL language has added support for a more familiar syntax for conditional expressions (if ... then ... else ...). Conditional DML can now be used to create, update, and delete various objects based on specified conditions. Functions like to_bytes(), to_str(), enc::base64_encode, and enc::base64_decode have been introduced. The use of the "when" expression is now permitted in triggers.
    select if count(Object) > 0 then ‘got data’ else ‘no data’;
    select (select User filter .name = ‘Alice’) ??
    (insert User { name := ‘Alice’ });
    select enc::base64_encode(b’hello’);
  • A new method for passing global values in GraphQL queries has been added—rather than using a separate field, it is now possible to pass variables based on the __globals__ object.

    Source: opennet.ru
Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster