在模式图中,一个属性(外键)指向不同表的另一个属性。我可以将表指向表,但不能将属性指向属性。
您只需修改我的以下 MWE 即可得到以下结果。一个从到dept_name
的instructor
箭头。dept_name
department
MWE(取自@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}
我的 MWE 输出
答案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}