Fix bugs, MLD graphs now seem well generated
[erdiag.git] / README.md
... / ...
CommitLineData
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
8*TODO list:* functional integrity constraints (CIF), inter-relations constraints (or, and, xor...), inheritance with the right symbol (triangle).
9
10*Note:* temporary dependency to [underscore](http://underscorejs.org/); good library but used so far only for its shuffle() method.
11
12-----
13
14An entity is defined as follow
15
16 [Entity]
17 #attr1 (*)
18 attr2 (*)
19
20with (\*) = optional SQL indications, and # denoting a (part of) a key.
21
22A relationship is defined in this way
23
24 {Relation}
25 Entity C1
26 Entity2 C2
27 --
28 attr1 (*)
29 attr2 (*)
30
31where attributes are optional, and C1 (resp. C2) = cardinality for entity 1 (resp. 2).
32Defining relationships with more than two attributes is easy: just add entities.
33Cardinality dictionary:
34 * \* = 0..n
35 * \+ = 1..n
36 * 1 = 1..1
37 * ? = 0..1
38
39Special cardinalities are also available to indicate relative identification: `?R` and `1R`.
40
41To mark a weak entity, just surround its name by extra-brackets
42
43 [[WeakEntity]]
44
45In the same way, a weak relation can be written
46
47 {{WeakRelation}}
48
49The syntax for these two last is then the same as in the non-weak versions.
50
51To indicate an inheritance relation, proceed as follow
52
53 is_a
54 Animal Cat Fish
55 Planet Mars Venus
56
57Finally, blocks must be separated by new lines. For a usage example, see example.html (it should render as seen in example\_\*.svg)
58
59Note that the "drawMcd" method can take a second argument, which indicates the type of graph.
60 * "bubble" draws the standard graph, as seen [here](https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model#/media/File:ER_Diagram_MMORPG.png) for example
61 * "compact" (default) use the same box for an entity and its attributes