'update'
[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
ae81f305 8*Note:* at the moment only the conceptual graph is implemented, and no comments are allowed in textual descriptions.
48a55161
BA
9At least the former is planned, and also probably a way to indicate relative identifiers, and maybe links between relationships.
10
11*Note bis:* temporary dependency to [underscore](http://underscorejs.org/); good library but used so far only for its shuffle() method.
525c4d2a
BA
12
13-----
14
15An entity is defined as follow
fe021b27 16
bf4fc3ed
BA
17 [Entity]
18 #attr1 (*)
19 attr2 (*)
fe021b27 20
525c4d2a
BA
21with (\*) = optional SQL indications, and # denoting a (part of) a key.
22
23A relationship is defined in this way
fe021b27 24
bf4fc3ed
BA
25 {Relation}
26 Entity C1
27 Entity2 C2
28 --
29 attr1 (*)
30 attr2 (*)
fe021b27 31
525c4d2a
BA
32where attributes are optional, and C1 (resp. C2) = cardinality for entity 1 (resp. 2).
33Defining relationships with more than two attributes is easy: just add entities.
34Cardinality dictionary:
35 * \* = 0..n
fe021b27 36 * \+ = 1..n
525c4d2a
BA
37 * 1 = 1..1
38 * ? = 0..1
39
40To mark a weak entity, just surround its name by extra-brackets
fe021b27 41
525c4d2a 42 [[WeakEntity]]
fe021b27 43
525c4d2a 44In the same way, a weak relation can be written
fe021b27 45
525c4d2a 46 {{WeakRelation}}
fe021b27 47
525c4d2a
BA
48The syntax for these two last is then the same as in the non-weak versions.
49
50To indicate an inheritance relation, proceed as follow
fe021b27 51
bf4fc3ed
BA
52 is_a
53 Animal Cat Fish
54 Planet Mars Venus
525c4d2a 55
fe021b27 56Finally, blocks must be separated by new lines. For a usage example, see example.html (it should render as seen in example.svg)
525c4d2a
BA
57
58Note that the "drawMcd" method can take a second argument, which indicates the type of graph.
59 * "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
60 * "compact" (default) use the same box for an entity and its attributes