Skip to content

Instantly share code, notes, and snippets.

@timm0e
Last active November 15, 2018 14:58
Show Gist options
  • Save timm0e/202dc6083645b9cd8a76d1145b20076e to your computer and use it in GitHub Desktop.
Save timm0e/202dc6083645b9cd8a76d1145b20076e to your computer and use it in GitHub Desktop.
Graphviz ER (Entity-Relationship) Example + VS Code snippets (incomplete)
graph ERD{
//Entities
node [shape=box;fillcolor=orange;style=filled]
Bundesland
Wahlkreis
Wahlbezirk
Direktkandidat
Partei
Wahlergebnis [peripheries=2]
Stimme
Erststimme [peripheries=2]
Zweitstimme [peripheries=2]
//Attributes
node [shape=ellipse;fillcolor=yellow;style=filled]
Bundesland -- {node [label = <<u>Name</u>>] bName}
Bundesland -- Einwohnerzahl
Wahlkreis -- Name
Wahlkreis -- {node [label = <<u>Nummer</u>>] wkNummer}
Wahlbezirk -- {node [label = <<u>Nummer</u>>] wbNummer}
Wahlbezirk -- Wahllokal
Wahlbezirk -- {node [label = "#Wahlberechtigte"] wahlberechtigte}
Direktkandidat -- {node [label = <<u>Name</u>>] dkName}
Direktkandidat -- {node [label = <<u>Sozialversicherungsnummer</u>>] svn}
Partei -- {node [label = <<u>Name</u>>] pName}
Partei -- {node [label = "#Mitglieder"] anzMitglieder}
Wahlergebnis -- Jahr
Wahlergebnis -- {node [label = <<u>I</u> <u>D</u>>] weID}
Stimme -- {node [label = "#Stimmen"] anzStimmen}
Stimme -- {node [label = <<u>I</u>&thinsp;<u>D</u>>] sID}
//Relationships
node [shape=diamond;fillcolor=lightgreen;style=filled]
{node [label = "liegt in"] liegtin}
Bundesland -- liegtin [taillabel="1"]
liegtin -- Wahlkreis [headlabel="N "]
{node [label = "unterteilt in"] unterteiltin}
Wahlkreis -- unterteiltin [taillabel="1"]
unterteiltin -- Wahlbezirk [headlabel="N"]
{node [label = "tritt an gegen"] trittan}
Direktkandidat -- trittan [taillabel="N"]
trittan-- Direktkandidat [headlabel=" N"]
{node [label = "tritt an in"] trittanin}
Direktkandidat -- trittanin [taillabel="N"]
trittanin -- Wahlkreis [headlabel=" 1"]
{node [label = "tritt an für"] trittanfuer}
Direktkandidat -- trittanfuer [taillabel="1"]
trittanfuer -- Partei [headlabel="1"]
{node [label = "erzielt";peripheries=2] erzielt}
Wahlbezirk -- erzielt [taillabel="1"]
erzielt -- Wahlergebnis [headlabel="N";color="black:invis:black"]
{node [label = "is-a";shape=hexagon;fillcolor=blueviolet;style=filled] isa}
Erststimme -- isa
Zweitstimme -- isa
isa -- Stimme[dir=forward]
{node [label = "liegen vor"] liegenvor}
Wahlergebnis -- liegenvor [taillabel=1]
liegenvor -- Erststimme [headlabel=N]
liegenvor -- Zweitstimme [headlabel=M]
{node [label = "ist zugeordnet";peripheries=2] kzugeordnet}
Direktkandidat -- kzugeordnet [taillabel=1]
kzugeordnet -- Erststimme [color="black:invis:black";headlabel=N]
{node [label = "ist zugeordnet";peripheries=2] pzugeordnet}
Partei -- pzugeordnet [taillabel=1]
pzugeordnet -- Zweitstimme [color="black:invis:black";headlabel=N]
}
{
"Underline node": {
"scope": "dot",
"prefix": "ul",
"body": "{node [label = <<u>${1}</u>>] ${2:prefix}${1}}$0",
"description": "Creates an underlined node"
},
"Unique node": {
"scope": "dot",
"prefix": "unique",
"body": "{node [label = \"$1\"] ${2:prefix}${1}}$0",
"description": "Creates an unique node"
},
"Label node": {
"scope": "dot",
"prefix": "lbl",
"body": "{node [label = \"$1\"] ${2:name}}$0",
"description": "Creates a node with a label"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment