Repository navigation
3.2 ER Diagrams
Great question. You can cover E/R + EER nicely in GitHub Wiki using only what GitHub renders natively:
- Mermaid for diagrams.
- MathJax for min–max/cardinality annotations.
- (Optionally) Mermaid flowchart/class diagrams to emulate EER features Mermaid-ER doesn’t natively show.
Below is a compact toolbox you can paste into your wiki and adapt.
Use Mermaid’s erDiagram for entities, attributes, and crow’s-foot cardinalities.
erDiagram
PERSON {
string DNI PK
string nombre
string direccion
}
HOUSE {
string id PK
string calle
int numero
}
MUNICIPALITY {
string id PK
string nombre
}
%% 1:N
PERSON ||--o{ HOUSE : HABITA
%% N:M
PERSON }o--o{ HOUSE : PROPIEDAD
%% N:1
HOUSE }o--|| MUNICIPALITY : UBICADA_EN
Tips:
-
||= “1”,o= “0”,{= “many”. - Put the Spanish verb as the edge label (e.g.,
"HABITA").
When you need
**Cardinalidades (min–max)**:
- HABITA: $PERSONA\ (1,N)$ — $VIVIENDA\ (0,N)$
- UBICADA\_EN: $VIVIENDA\ (1,1)$ — $MUNICIPIO\ (1,N)$Cardinalidades (min–max):
- HABITA:
$PERSONA\ (1,N)$ —$VIVIENDA\ (0,N)$ - UBICADA_EN:
$VIVIENDA\ (1,1)$ —$MUNICIPIO\ (1,N)$
(You can also put (0,1) or (1,N) as part of the edge label text in the ER diagram if you prefer.)
Mermaid-ER doesn’t have “doble borde”/weak notation. Two practical approximations:
- Nombra la entidad como
PAGO [débil]. - Añade una nota abajo: “Entidad débil: identificada por VÍNCULO con ALUMNO + clave parcial.”
flowchart LR
classDef weak stroke-width:3px,stroke-dasharray: 6 3,rx:6,ry:6
classDef ident stroke-width:3px,stroke:gray
ALUMNO([ALUMNO]):::ident -->|VÍNCULO IDENTIFICADOR| PAGO([PAGO]):::weak
note1[Clave parcial: Nº_Pago]:::weak
PAGO --- note1
Use este flowchart solo para ilustrar “débil + identificadora” cuando haga falta; mantén el ER principal en erDiagram.
Mermaid classDiagram funciona muy bien para jerarquías:
classDiagram
class EMPLEADO{
DNI
nombre
fecha_contratacion
}
class AGENTE
class ADMINISTRATIVO
EMPLEADO <|-- AGENTE
EMPLEADO <|-- ADMINISTRATIVO
%% Opcional: anota disjunta/solapada, total/parcial en una nota:
note for EMPLEADO "Especialización disjunta, parcial"
Añade al lado una línea con MathJax si quieres ser formal:
Disjunción: $AGENTE \cap ADMINISTRATIVO = \varnothing$; Totalidad: no (parcial).
Mermaid-ER no modela “atributos de relación” directamente. Dos trucos:
- Interponer entidad-join (estándar de paso a relacional):
erDiagram
CLIENTE ||--o{ RESERVA : ""
VIAJE ||--o{ RESERVA : ""
RESERVA {
string id PK
date fecha_reserva
int plazas
}
- Ternaria → representa con entidad intermedia nombrada con el verbo compuesto, y documenta en texto que es ternaria.
No hay “borde doble” automático. Anótalo en el label o en una lista bajo el diagrama:
**Participación**
- DIRIGE: *Total* en DEPARTAMENTO respecto a GERENTE.
- TRABAJA_PARA: *Total* en ambos sentidos. (Usa negritas/itálicas, o símbolos ✅/⚪ para total/parcial.)
erDiagram
PERSONA {
string id PK
string nombre
}
VIVIENDA {
string id PK
string direccion
}
MUNICIPIO {
string id PK
string nombre
}
PERSONA ||--o{ VIVIENDA : "HABITA"
PERSONA }o--o{ VIVIENDA : "PROPIEDAD"
VIVIENDA }o--|| MUNICIPIO : "UBICADA_EN"
classDiagram
class EMPLEADO{
DNI
nombre
fecha_contratacion
}
class RECEPCIONISTA{
idioma_principal
}
class CAMARERO{
area_asignada
}
EMPLEADO <|-- RECEPCIONISTA
EMPLEADO <|-- CAMARERO
Legend:
- 🔰 Start here
- 🏵️ Important Insight
- ⚙️ Technical and applications
- 💻 Some Code
- ⚜️ Advanced Topics
- 00.1 What Is Data?
-
00.2 Three Models of Reality (planned)
- 00.2.1 The Linguistic
- 00.2.2 The Symbolic
- 00.3.3 The Mathematical
- 00.3 Maps and Reality
- 00.4 Aside: Hossack, data as structure
- 00.5 Aside: Chomsky, data as evidence
- 01.1 🔰 Sets and Logic (planned)
- 01.2 Sample Space
- 01.3 Randomness and Pattern
- 01.4 Outcomes and Events
- 01.5 Finite and Infinite Sample Spaces
- 02.1 🔰 Functions (planned)
- 02.2 Types Are Alphabets
- 02.3 Random Variables: X : Ω → 𝒳 (planned)
- 02.4 Measurement Scales
- 02.5 Numerics
- 03.1 🔰 Fractions and Proportions (planned)
- 03.2 Randomness vs Uncertainty
- 03.3 Probability: Events, Conditioning, Bayes
- 03.4 Bayes' Theorem, Step by Step
- 03.5 Expected Value and Variance (planned)
- 03.6 Bernoulli (ES)
- 03.7 Discrete Uniform (ES)
- 03.8 🧗 Kolmogorov: Ω, 𝒜, ℙ
- 04.1 🔰 Powers and Logarithms (planned)
- 04.2 Rarity
- 04.3 Information Theory (Shannon)
- 04.4 Entropy: Three Views
- 05.1 🔰 Sums and Averages (planned)
- 05.2 Data, Measured
- 05.3 Sampling (ES)
- 05.4 Population and Sample (ES)
- 05.5 Types of Sampling (ES)
- 05.6 Choosing Summaries & Visuals
- 05.7 Visualization
- 05.8 Plots
- 06.1 What Is Statistics?
- 06.2 🔰 Curves and Area (planned)
- 06.3 Statistical Thinking
- 06.4 Variation
- 06.5 Uncertainty
- 06.6 Parameters vs Estimators (ES)
- 06.7 Distributions
- 06.8 Statistical Modeling
- 06.9 Statistical Methods
- 07.1 Data Storage: Databases (stub)
- 07.2 ER Diagrams
- 07.3 Chen Diagrams
- 07.4 SQL (planned)
- 07.5 Formal Languages and Regular Expressions (planned)
- 07.6 Reproducibility (planned)
08 · μ(x) — Fuzzy - When data is flexible
- 08.1 Fuzzy Logic (planned)
- 08.2 Fuzzy Numbers (planned)
- 08.3 Possibility vs Probability (planned)
09 · x(t) — Signals and systems - Where patterns live
- 09.1 Signals (stub)
- 09.2 Sampling and Aliasing (planned)
- 09.3 Convolution (planned)
- 09.4 Frequency (planned)
- 10.1 🔰 Vectors and Matrices (planned)
- 10.2 Mathematical Modelling (planned)
- 11.1 🔰 Derivatives (planned)
- 11.2 Convex Optimisation (planned)
- 12.1 Supervised Learning (planned)
- 12.2 Data in Language Models
- 13.1 Cause and Effect (planned)
- 13.2 Capstone Guide (planned)