Dependency diagrams using Tikz
I read about the rectangle split
node yesterday, so this was a chance to experiment. The code is far from perfect, but a good starting point:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm,landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart, calc}
\begin{document}
\begin{tikzpicture}[my shape/.style={
rectangle split, rectangle split parts=#1, draw, anchor=center}]
\node [my shape=7, rectangle split horizontal,name=dedi, rectangle split part fill={olive!50, blue!70, olive!50, blue!70}] at (0,0)
{PROJ\_NUM%
\nodepart{two} PROJ\_NAME
\nodepart{three} EMP\_NUM
\nodepart{four} EMP\_NAME
\nodepart{five} JOB\_CLASS
\nodepart{six} CHG\_HOUR
\nodepart{seven} HOURS};
\draw[latex-latex, very thick, red!70!black] (dedi.two north) -- ++(0,1) -| (dedi.four north);
\draw[latex-latex, very thick, red!70!black] (dedi.five north) -- ++(0,1) -| (dedi.four north);
\draw[latex-latex, very thick, red!70!black] (dedi.six north) -- ++(0,1) -| (dedi.four north);
\draw[latex-latex, very thick, red!70!black] (dedi.seven north) -- ++(0,1) -| (dedi.four north);
\draw[very thick, red!70!black] (dedi.one north) -- ++(0,0.5) -| (dedi.three north);
\draw[-latex, very thick, red!70!black] (dedi.one south) -- ++(0,-0.5) node[below right, text width=3cm] {\scriptsize partial dependancy} -| (dedi.two south);
\draw[-latex, very thick, red!70!black] ($(dedi.five south) + (0.2,0)$) -- ++(0,-0.5) node[below right, text width=2cm] {\scriptsize Transitive dependancy} -| ($(dedi.six south) + (-0.2,0)$);
\draw[-latex, very thick, red!70!black] (dedi.three south) -- ++(0,-2) -| (dedi.four south);
\draw[-latex, very thick, red!70!black] (dedi.three south) -- ++(0,-2) -| (dedi.five south);
\draw[-latex, very thick, red!70!black] (dedi.three south) -- ++(0,-2) -| node[below left] {\scriptsize partial dependancies} (dedi.six south);
\draw[-latex, very thick, red!70!black] (dedi.three south) -- ++(0,-2) -| (dedi.seven south);
\end{tikzpicture}
\end{document}
Have you seen the announcement of the tikz-dependency
package in comp.text.tex
?
http://www.ctan.org/pkg/tikz-dependency
for fun and exercise ...
pure tikz
solution:
\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, chains, positioning, shadows}
\begin{document}
\begin{tikzpicture}[
node distance = 7mm and 0mm,
start chain = A going right,
box/.style = {rectangle, draw, fill=#1,
minimum height=7mm, outer sep=0pt,
font=\bfseries\sffamily, text=white,
drop shadow, on chain=A},
box/.default = black!30!blue!50,
lbl/.style = {anchor=north, align=center, inner ysep=2pt,
font=\sffamily\footnotesize\linespread{0.8}\selectfont},
arr/.style = {draw=purple, -Triangle, ultra thick},
every edge/.style = {arr}
]
\node [box=olive] {PROJ\_NUM}; % A-1
\node [box] {PROJ\_NAME};
\node [box=olive] {EMP\_NUM};
\node [box] {EMP\_NAME};
\node [box] {JOB\_CLASS};
\node [box] {CHG\_HOUR};
\node [box] {HOURS}; % A-7
\coordinate[above=of A-2] (aux1);
\coordinate[above=of aux1] (aux2);
\coordinate[below=of A-2] (aux3);
\coordinate[below=of aux3] (aux4);
% arrows above nodes
\draw[arr] (A-1) |- (aux1) -| (A-3);
\draw[arr] (aux2) -| (A-7);
\draw (aux2) edge (A-2)
(aux2 -| A-4) edge (A-4)
(aux2 -| A-5) edge (A-5)
(aux2 -| A-6) edge (A-6);
% arrows below nodes
\draw[arr] (A-1) |- node[lbl,pos=0.75] {Partial\\ dependancy} (aux3) -- (A-2);
\draw[arr] (A-3) -- (A-3 |- aux4) -| node[lbl,pos=0.25] {Partial dependancy} (A-7);
\draw (aux4 -| A-4) edge (A-4)
(aux4 -| A-5) edge (A-5)
(aux4 -| A-6) edge (A-6);
\draw[arr] ([xshift= 5mm] A-5.south) -- ([xshift= 5mm] A-5.south |- aux3) -|
node[lbl,pos=0.25] {Transitive\\ dependancy}
([xshift=-5mm] A-6.south);
\end{tikzpicture}
\end{document}