erDiagram
{{ $sc := .showComment -}}
{{ $sd := .showDef -}}
{{- range $j, $r := .Relations }}
{{- if $r.HideForER }}{{ continue }}{{ end }}
"{{ $r.Table.Name }}" {{ $r.Cardinality | lcardi }}--{{ $r.ParentCardinality | rcardi }} "{{ $r.ParentTable.Name }}" : "{{ if $sd }}{{ $r.Def }}{{ end }}"
{{- end }}

"{{ .Table.Name }}" {
{{- range $i, $c := .Table.Columns }}
  {{- if $c.HideForER }}{{ continue }}{{ end }}
  {{ $c.Type | escape_mermaid }} {{ $c.Name }}{{ if $c.PK }} PK{{ end }}{{ if $c.FK }} FK{{ end }}{{ if $sc }} "{{ if ne $c.Comment "" }}{{ $c.Comment | escape_nl }}{{ end }}"{{ end }}
{{- end }}
}

{{- range $i, $t := .Tables }}
"{{ $t.Name }}" {
{{- range $ii, $c := $t.Columns }}
  {{- if $c.HideForER }}{{ continue }}{{ end }}
  {{ $c.Type | escape_mermaid }} {{ $c.Name }}{{ if $c.PK }} PK{{ end }}{{ if $c.FK }} FK{{ end }}{{ if $sc }} "{{ if ne $c.Comment "" }}{{ $c.Comment | escape_nl }}{{ end }}"{{ end }}
{{- end }}
}
{{- end }}
