Quote:
Originally Posted by JKeegan
My understanding is that the decomposition is incomplete because the decomposed relations can contain redundant info and have update, insert and deletion anomalies. Am I right in thinking that?
|
The decomposition is incomplete because you have information about multiple relationships contained in one table. If one relationship changes while the other remains the same, this creates the insert/update/delete problems you describe.
Redundant information shouldn't be confused with information that could be, or is, similar in multiple rows. Consider the following sample data:
Code:
registration # | color | make | model | engine size
----------------+-------+-------+---------+-------------
1 | red | mazda | protege | 4 cylinder
2 | blue | mazda | protege | 4 cylinder
3 | red | mazda | protege | 4 cylinder
4 | green | mazda | miata | 6 cylinder
The fact that there are 2 red mazda proteges does not mean that there is redundant/duplicate information in the table. Since they have different registration numbers, this indicates that these are two distinct cars that happen to have the same characteristics. If something changes about one car, that doesn't mean something changes about the other. For example, let's say we decide to paint car #3 blue, now we have:
Code:
registration # | color | make | model | engine size
----------------+-------+-------+---------+-------------
1 | red | mazda | protege | 4 cylinder
2 | blue | mazda | protege | 4 cylinder
3 | blue | mazda | protege | 4 cylinder
4 | green | mazda | miata | 6 cylinder
However, now let's say car #3 was entered incorrectly. It's actually a miata, not a protege. This results in:
Code:
registration # | color | make | model | engine size
----------------+-------+-------+---------+-------------
1 | red | mazda | protege | 4 cylinder
2 | blue | mazda | protege | 4 cylinder
3 | blue | mazda | miata | 4 cylinder
4 | green | mazda | miata | 6 cylinder
But the miata isn't a 4-cylinder car, it's a 6-cylinder car. The relationship between the registration number and type of car has changed (car #3 is now a miata), but the relationship between the type of car and engine size has remained the same (proteges have 4-cylinder engines, miatas have 6-cylinder engines). Since the table isn't normalized, we have an update anomaly. In order to fix this, we would need to make a second update to correct the engine size:
Code:
registration # | color | make | model | engine size
----------------+-------+-------+---------+-------------
1 | red | mazda | protege | 4 cylinder
2 | blue | mazda | protege | 4 cylinder
3 | blue | mazda | miata | 6 cylinder
4 | green | mazda | miata | 6 cylinder
See how this update is different from the previous updates? We did NOT update the engine size because we changed out the engine in the car, but because we changed other information in the row (specifically, the type of car). In a properly normalized database, we would not need to make this second update, because we know that all miatas have a 6-cylinder engine.
Now consider that the miata actually has a 4-cylinder engine. In our current table, we would need to make this change in all rows with a miata. In a properly normalized database, we would only need to make this change once. Consider what is changing here: we are not updating information about people's car registration -- nobody's vehicles have actually changed -- instead we are updating information about the car type itself.