Converting One-to-Many Relationships to One-to-One in Data Warehousing
In a transactional database, one-to-many relationships are very common. For example, one product may belong to multiple categories, and one person may have multiple addresses. In data warehousing, however, we often need only a one-to-one relationship for data analytics. Here are some common ways to convert a one-to-many relationship in the source table. 1. Add Multiple Columns One way to convert a one-to-many relationship to a one-to-one relationship is by adding more columns to the target table. This method is sometimes called “flattening.” For example, if a customer has up to three phone numbers and is represented in a source table CustomerPhone as follows: CustomerPhoneID CustomerID Phone 1 123 555-1111 2 123 555-2222 3 123 555-3333 In the target table, we can have three columns for Phone: Phone1, Phone2 and Phone3. To "flatten" the so...