Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to draw a database dependency diagram, similar to the one shown below

(Gaaah! I can't upload images. ASCII art it is then...)

  +------+------+------+------+------+------+
  |      |      |      |      |      |      |
  |      v      |      v      v      v      v
+---+  +---+  +---+  +---+  +---+  +---+  +---+      Lines extend from 1 and 3,
| 1 |  | 2 |  | 3 |  | 4 |  | 5 |  | 6 |  | 7 |      join above 2, and then route
+---+  +---+  +---+  +---+  +---+  +---+  +---+      to all other blocks

I've managed to get the easy bits done, namely drawing the blocks. I assume that I need to create a number of control points that the arrows must move through to 'raise' them above the nodes. What I can't get is to have them drawn nice and square.

Source diagram

Theres also the problem of the junction point above PROJ_NAME (block 2). PROJ_NUM (block 1) and EMP_NUM (block 3) together form a junction, and this junction joins to all the others. My Tikz attempt (although visually very far from what I want) illustrates this (I think?)

Please could someone point me in the right direction? Am I on the right track, is there a way easier method of doing this?

\tikzstyle{line} = [draw, -latex']
\tikzstyle{block} = [rectangle, draw, text centered, rounded corners, 
    minimum height=1.5em,font=\tiny]
\tikzstyle{cntrl} = [node distance=2em, minimum height=0]

\begin{tikzpicture}
    [shorten >=1pt,node distance=0.1em,auto,scale=0.5]        

    \node[block]    (n1)                     {PROJ\_NUM};
    \node[block]    (n2)  [right =of n1]     {PROJ\_NAME};
    \node[block]    (n3)  [right =of n2]     {EMP\_NUM};                                         
    \node[block]    (n4)  [right =of n3]     {EMP\_NAME};
    \node[block]    (n5)  [right =of n4]     {JOB\_CLASS};
    \node[block]    (n6)  [right =of n5]     {CHG\_HOUR};
    \node[block]    (n7)  [right =of n6]     {HOURS};

    \node[cntrl]    (i1)     [above =of n1]                  {};
    \node[cntrl]    (i2)     [above =of n2]                  {};
    \node[cntrl]    (i3)     [above =of n3]                  {};
    \node[cntrl]    (i4)     [above =of n4]                  {};
    \node[cntrl]    (i5)     [above =of n5]                  {};
    \node[cntrl]    (i6)     [above =of n6]                  {};
    \node[cntrl]    (i7)     [above =of n7]                  {};

    \path [line] (n1) .. controls (i1) and (i2) .. (n2);
    \path [line] (n3) .. controls (i3) and (i2) .. (n2);
    \path [line] (i2) .. controls (i2) and (i4) .. (n4);
    \path [line] (i2) .. controls (i2) and (i5) .. (n5);
    \path [line] (i2) .. controls (i2) and (i6) .. (n6);
    \path [line] (i2) .. controls (i2) and (i7) .. (n7);

\end{tikzpicture}    

Links to diagrams that I uploaded. Hopefully the links remain active..

Attempt so far: Tikz attempt so far

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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}

enter image description here

share|improve this answer
    
That will do swimmingly. Thank you. –  His Royal Redness Jan 21 '12 at 9:14
add comment

Have you seen the announcement of the tikz-dependency package in comp.text.tex?

http://www.ctan.org/pkg/tikz-dependency

share|improve this answer
    
No, I wasn't aware of the package. Not quite want I want for this scenario, but good to know anyway. Thanks! –  His Royal Redness Jan 21 '12 at 9:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.