Database Normalization for the Real World
Database normalization is the practice (sometimes practice and practice and practice) of optimizing table structures and organizing the data into tables so the data will always be as unambiguous as intended. Normalization allows you to adapt to changing business rules, changing requirements, and changing data without having to restructure the entire system.
By altering the way you store your datajust a little bitand changing the programs that are accessing that information, you can eliminate many opportunities for incorrect or corrupt data and ease the effort required for updating information.
One of the banes of a company's existence is the statement, "We have always done it that way." We have always stored the information like that; we have always allowed people to just put anything into that <insert field name>; we have always programmed that way. That isn't always a bad thing, especially when a company is young and learning. Yet, sometimes "the way things have always been done" may need to be revisited and revised when there is a new system and a better way of doing things. Normalizing data is one of the times and ways that are an advantage to the company to adopt.
Although data can be stored in a relational database similar to the way it would be stored in a flat file for use by a COBOL program (like a file layout that any COBOL programmer is familiar with), that process isn't necessarily the best way of doing it, especially if you are simply carrying the ideas of the past over into the present because you don't understand the difference or are afraid of change.
NOTE
Dictionary.com defines normalization this way: "To make normal, especially to cause to conform to a standard or norm," or "The imposition of a standard." Oh that's helpful. Webopedia says normalization is: "In relational database design, the process of organizing data to minimize redundancy. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships" I like this definition better....
Terminology
Before you look at normalization in connection with a real-world example of insurance information, you need to become comfortable with some of the terminology that is used in the discussion. When dealing with databases, and particularly on the subject of normalization, a whole new set of words are particularly useful, as described in the following sections.
-
Relation. Basically, a relation is a two dimensional table or array containing rows and columns.
-
Relationship. A relationship is the way that data in different tables relate to each other. The relationships, both between the data items forming the various entities in the tables and between the table entities themselves, form the basic core problem of database normalization. There are three basic types of data relationships, and it is important that you have an idea of what they are:
-
Attribute. An attribute is considered to be a changeable property or characteristic of some component of a program or database that can be set to different values or a column in a relation or table.
-
Tuple. A tuple is an ordered set of values or a set of value attributes in a relational database or a record in a non-relational database: a row in a relation.
-
Deletion anomaly. A deletion anomaly is data inconsistency or unintentional loss of data (or information) due to the deliberate deletion of other data.
-
Insertion anomaly. An insertion anomaly causes an inability to add information to the database due to a lack (either temporary or longer term) or absence of other data.
-
Update anomaly. An update anomaly is data inconsistency due to either data redundancy or the incomplete update of the redundant data.
-
Decomposition of a relation. Decomposition of a relation is splitting a single relation into multiple relations to enable the relation to be in a more normal form.
-
Data redundancy. Data redundancy is unnecessary repetition of data within a database.
-
Data integrity. Data integrity is the consistency of data in the database. It is important to have data integrity so your users know that they can rely on the data to be correct and that the results of their queries and programs will be accurate and expected.
-
Atomic value. An atomic value is a value that is neither a set of values that can be further broken down, nor a repeating group. Each column should be an entire value, but only one valuea value that is not typically broken down into subparts that are used by either the database or the users accessing the information from the database.
-
Referential integrity rule. The referential integrity rule says that the value stored in a non-nullable foreign key must be an actual key value in some relation.
-
Foreign key. A foreign key is a set of attributes (one or more columns) in one relation that is also a key in some (either the same or some other) relation. It is the logical link between relations. A foreign key that references its own relation is referred to as a recursive foreign key.
-
Functional dependency. Functional dependency means that the value of one attribute in a tuple (row) is determined by the value of another attribute in the same tuple. This is almost always the case with the primary key (the piece or pieces of information that makes a tuple unique) and the other information in the tuple. The city and state combination is dependent on the Zip code, even if more than one Zip code can be associated with a city in a given state. The legal identity of a person in the United States is dependent on that person's Social Security number.
-
Determinant. Attribute(s) on the left side of a functional dependency determine the value of other attributes in a tuple (the Zip code determines the city and state; the Social Security number determines the identity of the person; the license number and state determine the automobile ownership).
-
Entity integrity rule. The entity integrity rule says that a key attribute of a row may be null (you have to have a Zip code if you are a city; you have to have a license number and state if you are an automobile being driven on the road).
-
Constraint. A constraint is a rule that restricts the values in a database. Phone number has to be numeric; dollar amounts have to be numeric; state has to be a legal state or province; country has to have been a legal country at one time; date can't be February 31st.
One-to-one (1:1). A one-to-one relationship means that each and every instance of any given entity (not just most of them) relates to exactly one instance of another entity. Every person has exactly one right thumbprint that is unique. Every telephone number corresponds to exactly one billable entry for a private individual customer (not a company). Every person in the United States has exactly one Social Security number.
One-to-many (1:M). A one-to-many relationship means that each instance of a given entity can relate no instances, one instance, or more instances of another entity. Every person has zero biological children, one biological child, or more than one biological child. Every person has zero automobile, one automobile, or more than one automobile.
Many-to-many (M:N). A many-to-many relationship (zero, one or more instances of a given entity relate to zero, one or many instances of another entity) is a very difficult relationship to directly model, and it is one that is often decomposed into multiple 1:M relationships. Because of blended families, one or more children (siblings, step siblings, half-siblings) can have zero parents (orphaned), one parent (single-parent family), more than one parent (two parents either still together or divorced, or divorced and remarried). A house or property can be deeded to a single person (one in number, not to be confused with unmarried) or more than one person, and these same people (single or multiple in number) can have their names on the deed to more than one house or property.