In order to work with EQL, you need to understand the following concepts.
- Attribute: An attribute is the basic unit of a record schema. Attributes describe records in the Dgraph. From the point of view of assignments on records, an attribute can be either:
- Single-assign attribute: An attribute for which a record may have only one value. For example, because a book has only one price, the Price attribute would be single-assign. Single-assign attributes are of the atomic data type (such as
mdex:string
and mdex:double
).
- Multi-assign attribute: An attribute for which a record may have more than one value. For example, because a book may have more than one author, the Author attribute would be multi-assign. Multi-assign attributes are of the set data type (such as
mdex:string-set
and mdex:double-set
). They are represented in EQL by sets (see Sets and Multi-assign Data).
- Record: The fundamental unit of data in the Dgraph. Records are assigned attribute values. An assignment indicates that a record has a value for an attribute. A record typically has assignments from multiple attributes. Records in collections can include multiple assignments to the same attribute, as can records in EQL results.
- Collection: The full body of Dgraph application records is contained in one or more collections (called data sets in Studio). Thus, Dgraph data is collection-based rather than table-based. By using a
FROM
clause in your statement, you specify a named state. This serves as the record source for your query. (The named state references a collection name and the Dgraph database, for the data set.) Alternatively, theFROM
clause can specify a previously-defined statement as the record source. Note that a FROM
clause is mandatory in an EQL statement.
- Statement: A unit of EQL that computes related or independent analytics results. In EQL, a statement starts with
DEFINE
or RETURN
and ends with a semi-colon if it is between statements (the semi-colon is optional on the last statement). The statement also includes a mandatory SELECT
clause and, optionally, some other clause(s).
- Result: Query results are a collection of statement results; statement results are a collection of records.
- Intermediate results: Results from
RETURN
statements can also be used as intermediate results for further processing by other statements.
- Returned results: Set of matching values returned by the query or statement.
- Query: A request sent to the Dgraph Gateway (and ultimately to the Dgraph). In general, a query consists of multiple statements.