description | Entity-Relationship Diagrams Generator |
last change | Mon, 10 Dec 2018 15:21:00 +0000 (16:21 +0100) |
URL | [public ] git://auder.net/erdiag.git |
[private] git@auder.net:erdiag.git |
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.
6 years ago | master | shortlog | log | tree |