PGF/TikZ Manual

The TikZ and PGF Packages
Manual for version 3.1.9a


51 Entity-Relationship Diagram Drawing Library

  • TikZ Library er

  • \usetikzlibrary{er} % and plain
    \usetikzlibrary[er] % Cont

    This packages provides styles for drawing entity-relationship diagrams.

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

51.1 Entities

The package defines a simple style for drawing entities:

  • /tikz/entity(style, no value)

  • 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 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.

    (-tikz- diagram)

    \usetikzlibrary {er,positioning}
    \node[entity] (sheep) {Sheep};
    \node[entity] (genome) [right=of sheep] {Genome};
51.2 Relationships

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

51.3 Attributes
  • /tikz/key attribute(style, no value)

  • This style is intended for key attributes. By default, the will cause the attribute to be typeset in italics. Typically, underlining is used instead, but that looks ugly and it is difficult to implement in .