summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-er.tex
blob: b3503a60108294ca4f5b6730620d84b95c5b6637 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.


\section{Entity-Relationship Diagram Drawing Library}

\begin{tikzlibrary}{er}
  This packages provides styles for drawing entity-relationship
  diagrams. 
\end{tikzlibrary}

This library is intended to help you in creating E/R-diagrams. It defines
only very little new styles, but using these style |entity| instead of
saying |rectangle,draw| makes the code more expressive.


\subsection{Entities}

The package defines a simple style for drawing entities:

\begin{stylekey}{/tikz/entity}
  This style is to be used with nodes that represent entity types. It
  causes the node's shape to be set to a rectangle that is drawn and
  whose minimum size and width are set to sensible values.

  Note that this style is called |entity| despite the fact that it is
  to be used for nodes representing entity \emph{types} (the
  difference between an entity and an entity type is the same as the
  difference between an object and a class in object-oriented
  programming). If this bothers you, feel free to define a style
  |entity type| instead.
\begin{codeexample}[]
\begin{tikzpicture}
  \node[entity] (sheep)                   {Sheep};
  \node[entity] (genome) [right=of sheep] {Genome};
\end{tikzpicture}
\end{codeexample}
\end{stylekey}

\begin{stylekey}{/tikz/every entity}
  This stype is envoked by the style |entity|. To change the
  appearance of entities, you can change this style.
\begin{codeexample}[]
\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}
\end{codeexample}
\end{stylekey}



\subsection{Relationships}

Relationships are drawn using styles that are very similar to the
styles for entities.

\begin{stylekey}{/tikz/relationship}
  This style works like |entity|, only it is to be used for
  relationships. Again, |relationship|s are actually relationship types. 
\begin{codeexample}[]
\begin{tikzpicture}
  \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}
\end{codeexample}
\end{stylekey}

\begin{stylekey}{/tikz/every relationship}
  Works like |every entity|.
\begin{codeexample}[]
\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}
\end{codeexample}
\end{stylekey}



\subsection{Attributes}

\begin{stylekey}{/tikz/attribute}
  This style is used to indicate that a node is an attribute. To
  connect an attribute to its entity, you can use, for example, the
  |child| command or the |pin| option. 
\begin{codeexample}[]
\begin{tikzpicture}
  \node[entity] (sheep)  {Sheep}
    child {node[attribute] {name}}
    child {node[attribute] {color}};
\end{tikzpicture}
\end{codeexample}
\begin{codeexample}[]
\begin{tikzpicture}[every pin edge/.style=draw]    
  \node[entity,pin={[attribute]60:name},pin={[attribute]120:color}] {Sheep};
\end{tikzpicture}
\end{codeexample}
\end{stylekey}

\begin{stylekey}{/tikz/key attribute}
  This style is intended for key attributes. By default, the will
  cause the attribute to be typeset in italics. Typcially, underlining
  is used instead, but that looks ugly and it is difficult to
  implement in \TeX.
\end{stylekey}


\begin{stylekey}{/tikz/every attribute}
  This style is used with every (key) attribute.
\begin{codeexample}[]
\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}
\end{codeexample}
\end{stylekey}


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "pgfmanual-pdftex-version"
%%% End: