erdiag.git
descriptionEntity-Relationship Diagrams Generator
last changeMon, 10 Dec 2018 15:21:00 +0000 (16:21 +0100)

erdiag: Entity-Relationship Diagrams Generator

Inspired by this repository.

This parser reads ER diagrams definition files, and produces two types of diagrams + SQL code. Graphviz is used on server side to translate parsed graph descriptions into SVG objects.


An entity is defined as follow

[Entity]
+attr1 (*)
attr2 (*)

with (*) = optional SQL indications, and + denoting a (part of) an identifier.

A relationship is defined in this way

{Relation}
Entity C1
Entity2 C2
--
attr1 (*)
attr2 (*)

where attributes are optional, and C1 (resp. C2) = cardinality for entity 1 (resp. 2). Defining relationships with more than two attributes is easy: just add entities. Cardinality dictionary: * * = 0..n * + = 1..n * 1 = 1..1 * ? = 0..1

Special cardinalities are also available to indicate relative identification: ?R and 1R.

And, in case of a self-relationship, symbols ‘>’ and ‘<’ can indicate the sense, as in

{manage}
Users *>
Users 1<

To mark a weak entity, just surround its name by extra-brackets

[[WeakEntity]]

In the same way, a weak relation can be written

{{WeakRelation}}

The syntax for these two last is then the same as in the non-weak versions.

To indicate an inheritance relation, proceed as follow

is_a
Animal Cat Fish
Planet Mars Venus

Finally, blocks must be separated by new lines. For a usage example, see example.html (it should render as seen in example_*.svg); or example2.html for a bigger, more realistic illustration (small social network).

Note that the “drawMcd” method can take a second argument, which indicates the type of graph. * “bubble” draws the standard graph, as seen here * “compact” (default) use the same box for an entity and its attributes


TODO list:

Implementation note: temporary dependency to underscore; used only for its shuffle() method.

shortlog
2018-12-10 Benjamin AuderFix typo 'compact' --> 'graph' for output master
2018-12-10 Benjamin AuderRemove extra testing file
2018-02-12 Benjamin AuderForgot one conflict
2018-02-12 Benjamin Auderafter merge with remote
2018-02-11 Benjamin AuderAllow PNG file type, drop caching support
2018-02-08 Benjamin AuderFix readme # --> +
2018-02-07 Benjamin AuderComplete fix + add option in index.html for output...
2018-02-07 Benjamin AuderFix bug: regexp for 'REFERENCES' was case-sensitive
2018-02-07 Benjamin AuderOption to show dot input without running graphviz
2018-02-05 Benjamin AuderBasic web page to draw graphs from descriptions
2018-02-05 Benjamin Auderadd TODO
2018-02-03 Benjamin AuderBetter foreign key handling: correct SQL output
2018-02-03 Benjamin AuderDo not add extra 'NOT NULL' when irrelevant
2018-02-03 Benjamin AuderBetter foreign keys handling, slightly change SQL clues...
2018-02-02 Benjamin AuderImprove cardinality, detect duplicated fields after...
2018-02-02 Benjamin AuderFix doubling tables in n-ary relationships with 0,1...
...
heads
6 years ago master