Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit d6601b3

Browse files
committed
(GH-136) Complete anomalies sections
1 parent c4409e2 commit d6601b3

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

src/rdbms/normalization.txt

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ redundancy and dependency, making the database more efficient, flexible, and
1919
scalable. It also helps in maintaining data consistency and accuracy, and
2020
ensures that updates and deletions are properly handled.
2121

22-
There are 6 **normal forms**, but this chapter focuses on the first 3 only,
22+
There are 6 + 3 **normal forms**, but this chapter focuses on the first 3 only,
2323
since the commonest normal form you'll see out there is *3NF* (third normal
2424
form).
2525

@@ -39,17 +39,64 @@ Anomalies
3939
Insertion anomalies
4040
-------------------
4141

42-
.. todo: complete subsection
42+
There are circumstances in which certain facts cannot be recorded at all.
43+
For example, each record in the "Faculty and Their Courses" relation might
44+
contain a *Faculty ID*, *Faculty Name* and *Course Code*. Therefore, the
45+
details of any faculty member who teaches at least one course can be recorded,
46+
but a newly hired faculty member who has not yet been assigned to teach any
47+
courses cannot be recorded, except by setting the course code to ``null``.
48+
49+
+------------+----------------+-------------+
50+
| Faculty ID | Faculty Name | Course Code |
51+
+============+================+=============+
52+
| 389 | Dr. Headstrong | ENG-206 |
53+
+------------+----------------+-------------+
54+
| 407 | Dr. Mugwort | CMP-101 |
55+
+------------+----------------+-------------+
56+
| 407 | Dr. Mugwort | CMP-201 |
57+
+------------+----------------+-------------+
58+
59+
+------------+----------------+-------------+
60+
| Faculty ID | Faculty Name | Course Code |
61+
+============+================+=============+
62+
| 389 | Dr. Newone | ??? |
63+
+------------+----------------+-------------+
4364

4465
Update anomalies
4566
----------------
4667

47-
.. todo: complete subsection
68+
The same information can be expressed on multiple rows; therefore updates to
69+
the relation may result in logical inconsistencies. For example, each record
70+
in an "Employees' Skills" relation might contain ah *Employee ID*, *Employee
71+
Address*, and *Skill*; thus a charge of address for a particular employee may
72+
need to be applied to multiple records (one for each skill). If the update is
73+
only partially successful -- the employee's address is updated on some records
74+
but not others -- then the relation is left in an inconsistent state.
75+
Specifically, the relation provides conflicting answers to the question of what
76+
this particular employee's address is.
77+
78+
+-------------+-----------------------+-----------------+
79+
| Employee ID | Employee Address | Skill |
80+
+=============+=======================+=================+
81+
| 426 | 230 Parkland Crescent | typing |
82+
+-------------+-----------------------+-----------------+
83+
| 426 | 230 Parkland Crescent | shorthand |
84+
+-------------+-----------------------+-----------------+
85+
| 529 | 158 Watkins Place | public speaking |
86+
+-------------+-----------------------+-----------------+
87+
| 529 | 108 Church Street | carpentry |
88+
+-------------+-----------------------+-----------------+
4889

4990
Deletion anomalies
5091
------------------
5192

52-
.. todo: complete subsection
93+
Under certain circumstances, the deletion of data representing certain facts
94+
necessitates the deletion of data representing completely different facts.
95+
The "Faculty and Their Courses" relation described in the previous example
96+
suffers from this type of anomaly, for if a faculty member temporary ceases to
97+
be assigned to any courses, the last of the records on which that faculty
98+
member appears must be deleted, effectively also deleting the faculty member,
99+
unless the *Course Code* field is set to ``null``.
53100

54101
First normal form (1NF)
55102
=======================

0 commit comments

Comments
 (0)