Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how would one write a datomic query that takes the entire set into account

Is it possible to write these sort of queries in datomic?

  • find the name of the oldest kid
  • find the person with the lowest body-mass index (weight / height)
like image 352
zcaudate Avatar asked Apr 12 '13 12:04

zcaudate


People also ask

What is job of Datalog query?

It is often used as a query language for deductive databases. In recent years, Datalog has found new application in data integration, information extraction, networking, program analysis, security, cloud computing and machine learning.

Is Datomic fast?

Because Datomic queries run in application process space, they can be faster than any possible RPC query in some circumstances.


1 Answers

[:find (max ?tuple) :where 
    [?k :kid/age ?age] 
    [?k :kid/name ?name] 
    [(vector ?age ?name) ?tuple]

Note:

  • the order of attributes in expression (vector ?age ?name) matters

  • the query returns single result while we might expect a collection because there may be many kids of age that is the maximum in the set. You can use (max n ?tuple) to achieve that.

See also the Aggregates Returning Collections section in http://docs.datomic.com/query.html

If you have something more specific in mind, provide more details in the question and include your schema.

like image 165
Grzegorz Luczywo Avatar answered Nov 06 '22 00:11

Grzegorz Luczywo