Fix typo 'compact' --> 'graph' for output
[erdiag.git] / README.md
CommitLineData
525c4d2a
BA
1# erdiag: Entity-Relationship Diagrams Generator
2
3Inspired by [this repository](https://code.google.com/archive/p/merisier/).
4
5This parser reads ER diagrams definition files, and produces two types of diagrams + SQL code.
6[Graphviz](https://www.graphviz.org/) is used on server side to translate parsed graph descriptions into SVG objects.
7
525c4d2a
BA
8-----
9
10An entity is defined as follow
fe021b27 11
bf4fc3ed 12 [Entity]
0f208fab 13 +attr1 (*)
bf4fc3ed 14 attr2 (*)
fe021b27 15
0f208fab 16with (\*) = optional SQL indications, and + denoting a (part of) an identifier.
525c4d2a
BA
17
18A relationship is defined in this way
fe021b27 19
bf4fc3ed
BA
20 {Relation}
21 Entity C1
22 Entity2 C2
23 --
24 attr1 (*)
25 attr2 (*)
fe021b27 26
525c4d2a
BA
27where attributes are optional, and C1 (resp. C2) = cardinality for entity 1 (resp. 2).
28Defining relationships with more than two attributes is easy: just add entities.
29Cardinality dictionary:
30 * \* = 0..n
fe021b27 31 * \+ = 1..n
525c4d2a
BA
32 * 1 = 1..1
33 * ? = 0..1
34
19addd10
BA
35Special cardinalities are also available to indicate relative identification: `?R` and `1R`.
36
7a80e6db
BA
37And, in case of a self-relationship, symbols '>' and '<' can indicate the sense, as in
38
39 {manage}
40 Users *>
41 Users 1<
42
525c4d2a 43To mark a weak entity, just surround its name by extra-brackets
fe021b27 44
525c4d2a 45 [[WeakEntity]]
fe021b27 46
525c4d2a 47In the same way, a weak relation can be written
fe021b27 48
525c4d2a 49 {{WeakRelation}}
fe021b27 50
525c4d2a
BA
51The syntax for these two last is then the same as in the non-weak versions.
52
53To indicate an inheritance relation, proceed as follow
fe021b27 54
bf4fc3ed
BA
55 is_a
56 Animal Cat Fish
57 Planet Mars Venus
525c4d2a 58
3789126f
BA
59Finally, blocks must be separated by new lines. For a usage example, see example.html (it should render as seen in example\_\*.svg);
60or example2.html for a bigger, more realistic illustration (small social network).
525c4d2a
BA
61
62Note that the "drawMcd" method can take a second argument, which indicates the type of graph.
3789126f 63 * "bubble" draws the standard graph, as seen [here](https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#/media/File:ER_Diagram_MMORPG.png)
525c4d2a 64 * "compact" (default) use the same box for an entity and its attributes
5fe4fa10
BA
65
66-----
67
68**TODO** list:
69
70 - functional integrity constraints (CIF)
01cb2ab3 71 - inter-relations constraints (or, and, xor, inclusion)
5fe4fa10 72 - inheritance with the right symbol (triangle)
5fe4fa10 73
01cb2ab3 74*Implementation note:* temporary dependency to [underscore](http://underscorejs.org/); used only for its shuffle() method.