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