# Operator-Tree of relational Algebra

I'd like to create a relational algebra operator tree, I've already tried with forest or tikz-tree, but the problem is not the tree, the problem is to link the different operators. I would like to create this:

But this kind of figures aren't a tree, so it's difficult to me to create it. For example I don't know how to make a leaf ander sigma and a branch ander pi while pi is in the sigma subscript. The best I've could made is whith tiz-nodes and relations, but it doesn't look very well:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node  (empates) {{$\sigma_{Empates\ \ =\ \ }$}};
\node[right=-0.2cm of empates] (pi) {{$(\pi_{Num\_Empates}$}};
\node[below= of empates] (viewA) {View A};
\node[below= of pi]  (sigmatemporada) {{$\sigma_{A.temporada=t}$}};
\node[below= of sigmatemporada]  (f) {{$f_{MAX(EMPATES)}$}};
\draw (empates) -- (viewA);
\end{tikzpicture}
\end{document}


• Welcome to TeX.SE! You should show, what you tried so far. Writing an example from scratch is no fun ... Apr 8 '17 at 9:21
• I've add what I've tried. It doesn't look very weel but much better as what I've achieved whit tikz-tree. Thank for the Welcome! Apr 8 '17 at 10:02
• You can use an node anchor. For example node[ anchor=west]. Apr 8 '17 at 18:51
• Please always post complete code we can compile. A minimal document is key.
– cfr
Apr 8 '17 at 19:21
• @Serizba That's not really the point. Why don't you edit it so people don't have to do that? Especially with something where there are numerous libraries. If you were trying to help, would you be pleased if you had to hunt through the manual for the missing pieces?
– cfr
Apr 8 '17 at 20:10

You could put \sigma, \pi etc. in separate nodes. But take care of proper aligning:

\documentclass[border=5mm]{standalone}
\usepackage{tikz,amsmath}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[every node/.append style={inner sep=0pt, font=\vphantom{$f_p$}},
every path/.append style={shorten >=2.5pt, shorten <=2.5pt}]
\node (s1) {$\sigma$};
\node[right=-1pt of s1] (e1) {$_{Empates}$};

\node[below of=s1] (v1) {View A};

\node[right=15mm of s1] {$= \quad ($};

\node[right=25mm of s1] (p1) {$\pi$};
\node[right=-1pt of p1] (e2) {$_{Num\_Empates}$};

\node[below of=p1] (s2) {$\sigma$};
\node[right=-1pt of s2] (t1) {$_{A.Temporada \, = \, t}$};

\node[below of=s2] (f) {$f$};
\node[right=-1pt of f] (m1) {$_{\max(Empates)\, Num\_Empates}$};
\node[left=-1pt of f]  (m2) {$\genfrac{}{}{0pt}{}{temporada}{t}$};

\node[below of=f] (v2) {View};
\node[right=2mm of v2] {$)$};

\draw (s1) -- (v1);
\draw (s2) -- (p1);
\draw (p1) -- (s2);
\draw (s2) -- (f);
\draw (f)  -- (v2);
\end{tikzpicture}

\end{document}