]> git.somenet.org - pub/jan/adbs.git/blob - ex3/main_3.tex
tables
[pub/jan/adbs.git] / ex3 / main_3.tex
1 %ex3.3
2
3 \begin{enumerate}[label=(\alph*)]
4         \item\textbf{Two basic queries to start with:}
5         \begin{itemize}
6                 \item\textbf{List all the distinct countries for which addresses are
7                         registered in the database.}
8                         \begin{lstlisting}[style=command]
9 MATCH (n:Address) RETURN DISTINCT n.countries AS countries
10                         \end{lstlisting}
11                         This returns 222 different countries. We chose ''Austria''.
12                 \item\textbf{Choose one of these countries and list 5 entities which
13                         are based in that country.}
14                         \begin{lstlisting}[style=command]
15 MATCH (n:Address {countries: 'Austria'})<-[r:REGISTERED_ADDRESS]-(e:Entity)
16         RETURN DISTINCT e AS entity LIMIT 5
17                         \end{lstlisting}
18                         \input{results/result_3a.tex}
19         \end{itemize}
20         \item
21                 \begin{enumerate}[label=\roman*]
22                         \item\textbf{First, find the 10 \texttt{top intermediaries} , i.e.
23                                 those 10 intermediaries that have the most outgoing
24                                 \texttt{INTERMEDIARY\_OF} edges. Output the name of the
25                                 intermediary as well as the number of relevant edges.}
26                                 \begin{lstlisting}[style=command]
27 MATCH (n:Intermediary)-[r:INTERMEDIARY_OF]->()
28         RETURN n.name AS name, COUNT(r) AS count ORDER BY count DESC LIMIT 10
29                                 \end{lstlisting}
30                                 \input{results/result_3b1.tex}
31                         \item\textbf{Extend the query of \texttt{i} to also count outgoing
32                                 \texttt{OFFICER\_OF} edges to determine the top intermediaries.
33                                 Output the name of the intermediary as well as the number of
34                                 relevant edges.}
35                                 \begin{lstlisting}[style=command]
36 MATCH (n:Intermediary)-[r:INTERMEDIARY_OF|OFFICER_OF]->()
37         RETURN n.name AS name, COUNT(r) AS count ORDER BY count DESC LIMIT 10
38                                 \end{lstlisting}
39                                 \input{results/result_3b2.tex}
40                         \item\textbf{For the top intermediary from query \texttt{ii},
41                                 output all the outgoing edges, except for those that have type
42                                 either \texttt{OFFICER\_OF} or \texttt{INTERMEDIARY\_OF}. Also
43                                 output the respective nodes at the other side of the edges.}
44                                 \begin{lstlisting}[style=command]
45 MATCH (n:Intermediary {node_id: "54662"})-[r]->(t)
46         WHERE NOT (n)-[r:INTERMEDIARY_OF|OFFICER_OF]->(t)
47         RETURN type(r) AS relation, t.node_id AS node
48                                 \end{lstlisting}
49                                 \input{results/result_3b3.tex}
50                 \end{enumerate}
51 \end{enumerate}