Tikz ER 圖:一個實體之間的關係

Tikz ER 圖:一個實體之間的關係

我正在用 TikZ 繪製一個簡化的 ER 模型。這是到目前為止的程式碼:

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage{tikz}
\usetikzlibrary{er}
\usetikzlibrary{positioning,shapes,shadows,arrows}

\begin{document}

\begin{tikzpicture}[>=open triangle 90, thick,every node/.style={font=\footnotesize}, node distance = 6.2em]
node[entity] (page) {Page};
\node[relationship] (pageparent) [right of = page] {parent} edge node[above]{n...1} (page) edge (page);
\end{tikzpicture}

\end{document}

它會創造一個實體、一個關係物件以及這兩者之間的直邊。我需要這兩個物件之間的第二條邊來完成該圖,最好是這樣:

   |----------------------------|     
   |                            |
   |                            |
[ Page ] ----------------- < parent >

如何添加兩個 90° 角的第二條邊?

答案1

coordinate您可以透過以下定義 s 來做到這一點:

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage{tikz}
\usetikzlibrary{er}
\usetikzlibrary{positioning,shapes,shadows,arrows}

\begin{document}

\begin{tikzpicture}[>=open triangle 90, thick,every node/.style={font=\footnotesize}, node distance = 6.2em]
\node[entity](page){Page};
\node[relationship] (pageparent) [right of =page] {parent} edge node[above]{n...1} (page) edge (page);
\coordinate[above= 1cm of page] (cpage);
\coordinate[above= 0.8cm of pageparent] (cpageparent);
\draw[-] (page)--(cpage)--(cpageparent)--(pageparent);
\end{tikzpicture}

\end{document}

相關內容