Normalisation
Introducido
6:35
Bases de datos
A database is a set of true sentences about a domain. This course shows how to model, query, protect and govern data. The first three units model and shape it…
Narración en inglés · subtítulos en inglés y 中文 que puedes cambiar
En esta lección
| English | Significado |
|---|---|
| insert anomaly/ˈɪnsɜːt əˈnɒməli/ | anomalía de inserción |
| update anomaly/ˈʌpdeɪt əˈnɒməli/ | anomalía de actualización |
| delete anomaly/dɪˈliːt əˈnɒməli/ | anomalía de eliminación |
| functional dependency/ˈfʌŋkʃənl dɪˈpendənsi/ | dependencia funcional |
| Second normal form/ˈsekənd ˈnɔːml fɔːm/ | no non-key column depends on only part of a composite key |
| third normal form/θɜːd ˈnɔːml fɔːm/ | tercera forma normal |
| Boyce-Codd normal form/bɔɪs kɒd ˈnɔːml fɔːm/ | every determinant in the table is a candidate key |
| denormalisation/dɪˌnɔːməlaɪˈzeɪʃn/ | deliberately adding redundancy to a schema to make reads faster |
| lossless/ˈlɒsləs/ | Describing compression from which the original data can be recovered exactly. |
| spurious rows/ˈspjʊərɪəs rəʊz/ | wrong extra rows created when a table is split and joined back badly |
| attribute closure/ˈætrɪbjuːt ˈkləʊʒə/ | the set of all attributes that a given set of attributes determines through the functional dependencies |
| transitive dependence |
Las anomalías
- Una tabla desnormalizada invita a tres: una anomalía de inserción (no se puede agregar un curso sin estudiante), una anomalía de actualización (cambiar un dato en muchas filas), una anomalía de eliminación (perder el dato con la última fila que lo contiene). La enfermedad es el dato repetido.


Changing a course title in 14 enrollment rows is —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
One fact stored many times: the update anomaly.
Las dependencias impulsan la división
- Una dependencia funcional $A \to B$: cada valor A determina un solo valor B. Segunda forma normal elimina dependencias de clave parcial; tercera forma normal elimina las transitivas; Boyce-Codd hace que todo determinante sea una clave.
Enroll(student, course, title, dept, building):course → titlees clave parcial,title → dept → buildingtransitiva. Divida en Course, Dept, Enroll — cada dato una sola vez, cada anomalía eliminada.
What is the lowest normal form violated by a non-prime attribute depending on part of a candidate key?
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
2NF removes dependencies on part of the key; 3NF the transitive ones.
Put the steps of normalising a table in order.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
Each successive normal form adds constraints; identify the dependencies before decomposing the table.
Cuándo detenerse
Room(building, room, capacity, projector_type)con todas las salas de un edificio compartiendo un mismo tipo de proyector:building → projector_typees un determinante no clave — dividaBuilding(building, projector_type).- Un total acumulado almacenado es derivable, pero recalcularlo por vista puede costar más que el riesgo de anomalía: la desnormalización controlada con un desencadenante de actualización es legítima una vez comprendida la forma normal. Normalice para razonar; desnormalice con evidencia.
A non-key column determining a non-prime column breaks —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
A transitive chain through a non-key determinant is the 3NF violation.
Esta tarjeta se corrigió, por eso aparece en inglés hasta que se actualice su traducción.
Lossless splits
- A split must be lossless 无损: joining the parts gives back exactly the original rows. For a split into two parts, the shared columns must be a superkey of at least one part.
Enroll(student, course)andCourse(course, title, dept)sharecourse, the key of Course, so the join is exact. - Split on
titleinstead, into(student, title)and(course, title), and two courses with the same title join into spurious rows 伪元组 that were never there. 3NF can always be reached losslessly while keeping every dependency; a lossless BCNF decomposition can always be constructed but can lose a dependency.
R(A, B, C) with A → B is split into R1(A, B) y R2(A, C). The split is —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
The shared column A determines B, so it is a key of R1 and the join returns exactly the original rows.
A BCNF decomposition always preserves every functional dependency.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
A lossless BCNF decomposition can lose a dependency; a 3NF decomposition can always be both lossless and dependency-preserving.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Find the keys with closure
- The attribute closure 属性闭包 $X^+$ is everything that $X$ determines. For $R(A, B, C, D)$ with $A \to B$, $B \to C$, $C \to D$: $A^+ = \{A, B, C, D\}$, so $A$ alone is a key.
- $B^+ = \{B, C, D\}$ does not contain $A$, so $B$ is not a key. Closure turns "is this a key?" and "does this dependency follow?" into a mechanical check.
$R(A, B, C, D)$ with $A \to B$, $B \to C$, $C \to D$. $B^+$ is:
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
$B \to C \to D$, but nothing gives $A$.
In that relation, $A$ is a key.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
$A^+$ contains every attribute.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Worked example: 3NF but not BCNF
Teach(student, course, instructor): each instructor teaches one course (instructor → course), and a student has one instructor per course (student, course → instructor).instructoris a determinant but not a key, so the table is not in BCNF. Splitting into(instructor, course)and(student, instructor)is lossless 无损, but no single table now enforcesstudent, course → instructor. In this case 3NF is the better place to stop.
Teach(student, course, instructor), with exactly the dependencies instructor → course and student, course → instructor (and their consequences), is in BCNF.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Instructor determines course but is not a key.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Marks that slip away
- Splitting on a non-key. Split on
titleand two courses that share a title join into spurious rows. - Mixing up the two dependencies.
course → titlein the enrolment table depends on part of the key (a 2NF problem);title → dept → buildingis transitive (a 3NF problem). - Normalising past the evidence. Controlled denormalisation 反规范化 with a refresh rule is fine once measured reads need it.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Recap
- Anomalies come from repeated facts: insert, update and delete. Each normal form removes one cause:
| Form | Removes, with this lesson's case |
|---|---|
| 2NF | dependence on part of the key: course → title |
| 3NF | transitive dependence 传递依赖: title → dept → building |
| BCNF | a determinant that is not a key: instructor → course |
- Normalise to reason; denormalise when measurements show the need.
¿Qué salió mal? Solo el equipo del sitio ve esta información.