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