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 | ||
d23e4446 BA |
8 | **TODO** list: |
9 | ||
10 | - functional integrity constraints (CIF), | |
11 | - inter-relations constraints (or, and, xor...), | |
12 | - inheritance with the right symbol (triangle). | |
48a55161 | 13 | |
19addd10 | 14 | *Note:* temporary dependency to [underscore](http://underscorejs.org/); good library but used so far only for its shuffle() method. |
525c4d2a BA |
15 | |
16 | ----- | |
17 | ||
18 | An entity is defined as follow | |
fe021b27 | 19 | |
bf4fc3ed BA |
20 | [Entity] |
21 | #attr1 (*) | |
22 | attr2 (*) | |
fe021b27 | 23 | |
525c4d2a BA |
24 | with (\*) = optional SQL indications, and # denoting a (part of) a key. |
25 | ||
26 | A relationship is defined in this way | |
fe021b27 | 27 | |
bf4fc3ed BA |
28 | {Relation} |
29 | Entity C1 | |
30 | Entity2 C2 | |
31 | -- | |
32 | attr1 (*) | |
33 | attr2 (*) | |
fe021b27 | 34 | |
525c4d2a BA |
35 | where attributes are optional, and C1 (resp. C2) = cardinality for entity 1 (resp. 2). |
36 | Defining relationships with more than two attributes is easy: just add entities. | |
37 | Cardinality dictionary: | |
38 | * \* = 0..n | |
fe021b27 | 39 | * \+ = 1..n |
525c4d2a BA |
40 | * 1 = 1..1 |
41 | * ? = 0..1 | |
42 | ||
19addd10 BA |
43 | Special cardinalities are also available to indicate relative identification: `?R` and `1R`. |
44 | ||
525c4d2a | 45 | To mark a weak entity, just surround its name by extra-brackets |
fe021b27 | 46 | |
525c4d2a | 47 | [[WeakEntity]] |
fe021b27 | 48 | |
525c4d2a | 49 | In the same way, a weak relation can be written |
fe021b27 | 50 | |
525c4d2a | 51 | {{WeakRelation}} |
fe021b27 | 52 | |
525c4d2a BA |
53 | The syntax for these two last is then the same as in the non-weak versions. |
54 | ||
55 | To indicate an inheritance relation, proceed as follow | |
fe021b27 | 56 | |
bf4fc3ed BA |
57 | is_a |
58 | Animal Cat Fish | |
59 | Planet Mars Venus | |
525c4d2a | 60 | |
3ca1e50c | 61 | 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 |
62 | |
63 | Note that the "drawMcd" method can take a second argument, which indicates the type of graph. | |
64 | * "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 | |
65 | * "compact" (default) use the same box for an entity and its attributes |