More Database Design Mistakes To Avoid
One program that I inherited just wasn’t making sense.
The load of this program loaded data into a single table. It retrieved data into a few fields. Then did loop de loops, reading these initial fields, and compared them to hard coded values in the program. Finally updated the remaining fields, based on the hard coded values in the program.
Eventually it dawned on me. There was a functional dependency, violating 2NF. The first field, determined the second field. This of course should have been moved into another table, but it wasn’t.
Subsequently, we had to run distinct queries against the larger table, to find the list of codes, instead of in the lookup table.
Create the lookup table, and a one to many relationship.
In this case, a mapping table might also be created.
Oddly enough: The really crazy thing was, that both this mistake, too few tables, and the other mistake, of too many tables, were both done by the very same person!