2

In schema diagram one attribute(foreign key) points another attribute of different table. I can point table to table, but not attribute to attribute.

You just modify my following MWE that give the following result. One arrow from dept_name of instructor to dept_name of department.

enter image description here

MWE(taken from @marmot)

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning,shapes.multipart,shapes}
\begin{document}
\tikzset{basic/.style={
        draw,
        rectangle split,
        rectangle split parts=2,
        rectangle split part fill={blue!20,white},
        minimum width=2.5cm,
        text width=2cm,
        align=left,
        font=\itshape
    },
    Diamond/.style={ diamond, 
                        draw, 
                        shape aspect=2, 
                        inner sep = 2pt,
                        text centered,
                        fill=blue!10!white,
                        font=\itshape
                      }}
\begin{tikzpicture}
\node[basic] (instructor) {instructor
\nodepart{second}
\underline{ID}\\
name\\
salary};
\node[basic,right=5cm of instructor] (department) {department
\nodepart{second}
\underline{dept\_name}\\
building\\
budget};
\draw (instructor) -- (department);
\end{tikzpicture}
\end{document}

Output of my MWE

enter image description here

1
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc,positioning,shapes.multipart,shapes}
\begin{document}
\tikzset{basic/.style={
        draw,
        rectangle split,
        rectangle split parts=2,
        rectangle split part fill={blue!20,white},
        minimum width=2.5cm,
        text width=2cm,
        align=left,
        font=\itshape
    },
    Diamond/.style={ diamond, 
                        draw, 
                        shape aspect=2, 
                        inner sep = 2pt,
                        text centered,
                        fill=blue!10!white,
                        font=\itshape
                      }}
\begin{tikzpicture}
\node[basic] (instructor) {instructor
\nodepart{second}
\underline{ID}\\
name\\
dept\_name\\
salary};
\node[basic,right=5cm of instructor] (department) {department
\nodepart{second}
\underline{dept\_name}\\
building\\
budget};
\draw[->] ([yshift=-13pt]$(instructor.east)$) -- ([yshift=1pt]$(department.west)$);
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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