Skip to content

Commit

Permalink
More work on language CPs
Browse files Browse the repository at this point in the history
  • Loading branch information
szarnyasg committed Mar 20, 2018
1 parent 622f9a6 commit cb46e8a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
42 changes: 30 additions & 12 deletions choke-points.tex
Expand Up @@ -333,9 +333,9 @@ \section{Language Features}

\subsubsection{Description}

\todo{description}
\paragraph{Transitive edges.} TODO bound (3..5-style )or unbound

For example, the condition that a certain \texttt{message} does not have a certain \texttt{tag} is represented in the graph as the absence of a \texttt{hasTag} edge between the two nodes. Thus, queries looking for cases where this condition is satisfied check for the (also known as negative application conditions or NACs in graph transformation literature).
\paragraph{Negative edge conditions.} Some queries define \emph{negative edge conditions}. For example, the condition that a certain \texttt{message} does not have a certain \texttt{tag} is represented in the graph as the absence of a \texttt{hasTag} edge between the two nodes. Thus, queries looking for cases where this condition is satisfied check for the (also known as negative application conditions or NACs in graph transformation literature~\cite{DBLP:journals/fuin/HabelHT96}).

\subsubsection{Language-specific notes}

Expand All @@ -345,58 +345,69 @@ \subsubsection{Language-specific notes}
\item[Cypher.]
Prior to Neo4j version 2.0, Cypher queries used a syntax such as the following:

\begin{minipage}{\linewidth}
\begin{lstlisting}[language=cypher]
MATCH (source)-[r?:someType]->(target)
WHERE r IS NULL
RETURN source
\end{lstlisting}
\end{minipage}

In Neo4j 2.0, the \lstinline[language=cypher]{OPTIONAL MATCH} clause was introduced:\footnote{\url{https://dzone.com/articles/new-neo4j-optional}}

\begin{minipage}{\linewidth}
\begin{lstlisting}[language=cypher]
MATCH (source)
OPTIONAL MATCH (source)-[r:someType]->(target)
WHERE r IS NULL
RETURN source
\end{lstlisting}
\end{minipage}

However, the preferred method is to use a pattern condition in the \lstinline[language=cypher]{WHERE} clause:

\begin{minipage}{\linewidth}
\begin{lstlisting}[language=cypher]
MATCH (source)
WHERE NOT (source)-[:someType]->(target)
RETURN source
\end{lstlisting}
\end{minipage}

\item[G-CORE.] TODO

\item[SPARQL.]
Prior to SPARQL 1.1, queries with negative edge conditions used the following syntax:

\begin{minipage}{\linewidth}
\begin{lstlisting}[language=sparql]
OPTIONAL {
?xRoute ?routeDefinition ?xSensor .
FILTER (sameTerm(base:routeDefinition, routeDefinition))
} .
FILTER (!bound(?routeDefinition))
\end{lstlisting}
\end{minipage}

Since SPARQL 1.1, the preferred method is using the \lstinline{NOT EXISTS} construct.

Since SPARQL 1.1, the preferred method is using the \lstinline[language=sparql]{NOT EXISTS} construct.

\begin{minipage}{\linewidth}
\begin{lstlisting}[language=sparql]
?xSensor rdf:type base:Sensor .
?xRoute base:switchPosition ?xSwitchPosition .
FILTER NOT EXISTS { xRoute ?routeDefinition ?xSensor } .
\end{lstlisting}
\end{minipage}

The \lstinline{MINUS} construct can also be used for defining a negative condition for a single edge.\footnote{For details, see the ``Relationship and differences between NOT EXISTS and MINUS'' section in the SPARQL 1.1 specification: \url{https://www.w3.org/TR/sparql11-query/\#neg-notexists-minus}}

\begin{minipage}{\linewidth}
\begin{lstlisting}[language=sparql]
?xSensor rdf:type base:Sensor .
?xRoute base:switchPosition ?xSwitchPosition .
MINUS { xRoute ?routeDefinition ?xSensor } .
\end{lstlisting}
\end{minipage}

\end{description}

Expand All @@ -412,7 +423,7 @@ \subsubsection{Description}

Aggregations on aggregations, filtering on aggregation results (similarly to the \lstinline{HAVING} keyword of SQL).


TODO

\subsubsection{Language-specific notes}

Expand All @@ -432,13 +443,19 @@ \subsubsection{Language-specific notes}

\subsubsection{Description}

Selecting top-k with other graph elements/attributes.
Selecting top-k with other graph elements/attributes, also known as \emph{windowing} or \emph{ranking}.

PostgreSQL defines the \lstinline[language=sql]{rank()} function for this.\footnote{\url{https://www.postgresql.org/docs/9.1/static/tutorial-window.html}}

TODO

\subsubsection{Language-specific notes}

\begin{description}
\item[Cypher.] Ranking can be expressed in Cypher as a sequence of ordering, collecting results and taking the top-k values of the result list.
%\begin{description}
%\item[Cypher.]
Ranking can be expressed in Cypher as a sequence of ordering, collecting results and taking the top-k values of the result list.

\noindent\begin{minipage}{\linewidth}
\begin{lstlisting}[language=cypher]
...
WITH x, ...
Expand All @@ -447,11 +464,12 @@ \subsubsection{Language-specific notes}
WITH xs[0] AS top, xs[0..5] AS top5
...
\end{lstlisting}
\end{minipage}

\item[G-CORE.] TODO

\item[SPARQL.] TODO
\end{description}
%\item[G-CORE.] TODO
%
%\item[SPARQL.] TODO
%\end{description}

\input{query-cards/cp-8-3}

Expand Down
17 changes: 17 additions & 0 deletions ldbc-snb.bib
Expand Up @@ -298,3 +298,20 @@ @inproceedings{GCORE_SIGMOD
adsurl = {http://adsabs.harvard.edu/abs/2017arXiv171201550A},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

@article{DBLP:journals/fuin/HabelHT96,
author = {Annegret Habel and
Reiko Heckel and
Gabriele Taentzer},
title = {Graph Grammars with Negative Application Conditions},
journal = {Fundam. Inform.},
volume = {26},
number = {3/4},
pages = {287--313},
year = {1996},
url = {https://doi.org/10.3233/FI-1996-263404},
doi = {10.3233/FI-1996-263404},
timestamp = {Sat, 20 May 2017 00:23:06 +0200},
biburl = {https://dblp.org/rec/bib/journals/fuin/HabelHT96},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
2 changes: 0 additions & 2 deletions listings.tex
Expand Up @@ -17,8 +17,6 @@
stringstyle=\scriptsize,
%
showstringspaces=false,
aboveskip=3pt,
belowskip=3pt,
columns=flexible,
keepspaces=true,
breaklines=true,
Expand Down

0 comments on commit cb46e8a

Please sign in to comment.