I'm evaluating OrientDB and Neo4j in this simple toy example composed by:
- Employees, identified by
eid - Meetings, identified by
midand havingstartandendattributes encoding their start and end DateTime.
Both entities are represented by different classes of vertices, namely Employee and CalendarEvent, which are connected by Involves edges specifying that CalendarEvent-[Involves]->Employee.
My task is to write a query that returns, for each pair of employees, the date/time of their first meeting and the number of meetings they co-attended. In Cypher I would write something like:
MATCH (e0: Employee)<-[:INVOLVES]-(c:CalendarEvent)-[:INVOLVES]->(e1: Employee)
WHERE e0.eid > e1.eid
RETURN e0.eid, e1.eid, min(c.start) as first_met, count(*) as frequency
I wrote the following query for OrientDB:
SELECT eid, other, count(*) AS frequency, min(start) as first_met
FROM (
SELECT eid, event.start as start, event.out('Involves').eid as other
FROM (
SELECT
eid,
in('Involves') as event
FROM Employee UNWIND event
) UNWIND other )
GROUP BY eid, other
but it seems over-complicated to me. Does anybody knows if there is an easier way to express the same query?