| Lesson 8 | Multi-Valued Attributes |
| Objective | Understand multi-valued attributes, why they are problematic in relational databases, and how to resolve them. |
A multi-valued attribute is an attribute in a database entity that contains multiple distinct values for a single instance of the entity. Relational databases follow the one attribute, one value rule, meaning each attribute should hold only a single, atomic (indivisible) value per entity instance. Multi-valued attributes violate this rule and must be resolved to ensure a proper database design.
Example: Consider a Customer entity with an attribute Name. If the value is "Susan Anthony," this is not a multi-valued attribute, as it represents a single full name. However, if a Phone attribute contains two values (e.g., a home phone and a business phone), it is multi-valued, as it holds multiple distinct values for the same entity instance.
Why Split Composite Attributes? While "Susan Anthony" is not multi-valued, it is often split into FirstName and LastName attributes for practical reasons. For example, to generate a personalized salutation like "Dear Susan" in a form letter, the database needs access to the first name alone. Splitting composite attributes improves flexibility without violating the one-value rule.
Multi-valued attributes cause several issues in relational database design, impacting normalization, performance, and data integrity. The key problems include:
phone_numbers attribute can cause duplication if not properly managed.Person entity with a phone_numbers attribute requires a separate PhoneNumbers table, complicating the schema.Person and PhoneNumbers tables, increasing query complexity.Employee entity with multi-valued attributes dependents_names and dependents_birth_dates. Associating each name with the correct birth date (e.g., by position) is error-prone, and ensuring consistent updates across multiple values is challenging.phone_numbers attribute involves scanning each entry, degrading performance compared to normalized tables with indexes.type (e.g., mobile, home), a single multi-valued attribute cannot easily accommodate this without further restructuring.Multi-valued attributes must be resolved to comply with relational database principles and improve performance, scalability, and maintainability. There are two primary approaches:
Customer with a multi-valued Phone attribute could have Phone1, Phone2, and Phone3. This approach is simple but limited, as it imposes a fixed number of values and may lead to unused fields or insufficient slots.Example: For an Employee entity with a multi-valued skills attribute, create a separate Skills table and an EmployeeSkills table to represent the many-to-many relationship:
Employee table: EmployeeID, NameSkills table: SkillID, SkillNameEmployeeSkills table: EmployeeID, SkillIDThis structure allows an employee to have any number of skills, supports queries like “find all employees with a specific skill,” and avoids redundancy. Similarly, for an Employee with multi-valued dependents_names and dependents_birth_dates, a Dependents table (DependentID, EmployeeID, Name, BirthDate) ensures each dependent’s data is stored atomically and linked correctly.
Understanding and resolving multi-valued attributes is critical for designing normalized, efficient databases. The next lesson will explore how to apply normalization techniques to create a robust database schema.