Attributes-Entities   «Prev  Next»

Lesson 8 Multi-Valued Attributes
Objective Understand multi-valued attributes, why they are problematic in relational databases, and how to resolve them.

Resolve Multivalued Attributes: Distinct Columns or a New Table?

Start with the Meaning of Each Value

Resolve a multivalued attribute by identifying what its values represent. Use separate attributes when they express genuinely different, single-valued roles. Use related records when they are repeated occurrences of the same kind of fact. Simply creating Phone1, Phone2, and Phone3 does not resolve the underlying design problem.

A multivalued attribute can have several values for one entity instance, such as several phone numbers for one customer. Packing those independently meaningful facts into one field hides their structure. The previous lesson explains how to recognize these collections and their relationship to First Normal Form (1NF).

Example: A Customer attribute containing the full name Susan Anthony represents one name, not two names. Dividing a name into components is a separate design decision. If an application needs a preferred salutation, define and collect that information instead of assuming every full name can be split reliably into first and last names.

Atomicity concerns the intended domain and use of a value; it does not mean a value has no internal components. A date can contain year, month, and day components while remaining one date value.



Why Numbered Columns Do Not Solve the Problem

Phone1, Phone2, and Phone3 create slots rather than meaningful attributes. What distinguishes the second number from the first? What happens when a customer supplies a fourth? If the answer is merely list position, the design still represents a repeating group.

  • Arbitrary limits: Another occurrence requires another column and changes to forms and queries.
  • Unclear meaning: Applications must invent rules about position, order, and unused slots.
  • Repeated logic: Searching or validating every number requires checking several similar columns.
  • Fragile associations: Parallel lists of dependent names and birth dates can lose the pairing between each person and their date.

A separate table adds a relationship, but that relationship makes the facts explicit. Joins are a normal part of relational querying, not a defect introduced by normalization. Nor are packed lists literally impossible to search or index: the issue is whether the structure supports the required per-value meaning, constraints, and operations.


When Adding Distinct Attributes Is Appropriate

Separate attributes can be appropriate when each has a stable business definition and at most one value per entity instance. For example, a small customer system might record one current BillingPhone and one current ShippingPhone. These roles explain the purpose of each value independently of list order.

This design assumes that each role needs no more than one number, the roles are stable, and the system does not need contact-number history or independently managed contact records. A small number of values alone is not enough to justify separate columns.

Choose structure from the business meaning
RequirementSuitable direction
One billing and one shipping contact numberDistinct role attributes may be sufficient
Several numbers per role, each with notes or effective datesRelated contact records
Several children, each with a name and birth dateA child or dependent entity with appropriate relationships
Several shared skills per employeeSkill records and an EmployeeSkill association

Example: Two Defined Contact Roles

This illustrative PostgreSQL 18 example stores one current number per role. Phone numbers are text because punctuation, prefixes, and leading zeros are meaningful; they are not quantities for arithmetic. The length is illustrative and should follow the application's requirements.

CREATE TABLE CustomerContactExample (
    CustomerID INTEGER PRIMARY KEY,
    CustomerName VARCHAR(200) NOT NULL,
    BillingPhone VARCHAR(40),
    ShippingPhone VARCHAR(40)
);

INSERT INTO CustomerContactExample
    (CustomerID, CustomerName, BillingPhone, ShippingPhone)
VALUES
    (101, 'Example Supplies', '+1-202-555-0101', '+1-202-555-0199');

SELECT CustomerID, BillingPhone
FROM CustomerContactExample
WHERE BillingPhone IS NOT NULL;

The expected result includes customer 101 and its billing number. This is an illustrative outcome, not a captured execution result. In PostgreSQL, use IS NULL or IS NOT NULL to test missing values, as explained in the comparison documentation.

The same phone number may legitimately serve both roles, so this example does not require the two columns to differ. It also does not declare phone numbers globally unique: customers can share a switchboard or household number. Define uniqueness from the actual business rules.

Both role columns are optional here. NULL means no value is recorded; it does not distinguish unknown, unavailable, or not applicable. If those distinctions matter, model them explicitly. A VARCHAR declaration limits representation, but does not prove that a number is valid or reachable. Required fields and validation need separate rules.

Keep the Role Definition Clear

A change to BillingPhone should mean that the customer's current billing contact number changed. It should not mean that the first number was moved to another slot. RequestedDeliveryDate and ActualDeliveryDate provide another example of distinct roles: they describe different events, not arbitrary Date1 and Date2 positions.

If a customer later needs several shipping contacts, extensions, verification dates, or contact preferences, revisit the design. Repeating those groups as ShippingPhone1, ShippingPhone2, and ShippingPhone3 would reintroduce the problem.

When a New Entity Is the Better Choice

Use related records when occurrences can grow independently or each occurrence needs its own attributes, identifier, relationships, or history. A contact record can keep its number, role, and other details together while a foreign key identifies the customer it belongs to.

For an employee's skills, use an Employee table, a Skill table, and an EmployeeSkill association. The association represents which employee has which skill; proficiency or assessment dates can describe that association. A suitable key prevents duplicate memberships without preventing different employees from sharing a skill.

Likewise, related dependent records keep each name and birth date together. Do not use a person's name alone as identity. If the same dependent can be associated with multiple employees, the model may need a shared dependent entity and an association table.

Migrate Existing Values Without Guessing Their Roles

A list containing two phone numbers does not establish which one is for billing. Check the source definitions or confirm the roles with the data owner before populating named columns. Preserve unresolved values for review rather than assigning meaning from position.

Retain a source backup, document the mapping, and check that no values were silently dropped. Test customers with missing numbers, the same number in both roles, and more numbers than the proposed structure permits. Those cases reveal whether the assumptions fit the real data.


Next Steps

Adding attributes is appropriate when it makes distinct, single-valued roles explicit. Numbered slots merely distribute a collection across columns. When facts repeat or need independent management, represent them as related records.

Continue to resolving multivalued attributes by creating a new entity for the employee-and-children example. Review attribute domains when defining the permitted values and validation rules for each new attribute.


SEMrush Software 8 SEMrush Banner 8