绘制实体关系图要用到“er”库,所以请在LaTeX导言中加入
\usetikzlibrary{er}
实体用节点表示,只需在节点选项中加入
entity它受风格
every entity影响。比如
\begin{tikzpicture}
[every entity/.style={draw=blue!50,fill=blue!20,thick}]
\node[entity] (sheep) {Sheep};
\node[entity] (genome) [right=of sheep] {Genome};
\end{tikzpicture}
关系同样是节点,只需在节点选项中加入
relationship它受风格
every relationship影响。比如
\begin{tikzpicture}
[every entity/.style={fill=blue!20,draw=blue,thick},
every relationship/.style={fill=orange!20,draw=orange,thick,aspect=1.5}]
\node[entity] (sheep) at (0,0) {Sheep};
\node[entity] (genome) at (2,0) {Genome};
\node[relationship] at (1,1.5) {has}
edge (sheep)
edge (genome);
\end{tikzpicture}
属性同样也是节点,只需在节点选项中加入
attribute它受风格
key attribute影响。比如
every attribute
\begin{tikzpicture}
[text depth=1pt,every attribute/.style={fill=black!20,draw=black},
every entity/.style={fill=blue!20,draw=blue,thick},
every relationship/.style={fill=orange!20,draw=orange,thick,aspect=1.5}]
\node[entity] (sheep) at (0,0) {Sheep} child {node [key attribute] {name}};
\node[entity] (genome) at (2,0) {Genome};
\node[relationship] at (1,1.5) {has}
edge (sheep)
edge (genome);
\end{tikzpicture}