How would you handle a multivalue attribute like multiple phone numbers in a relational model?

Get ready for the GMetrix Data Modeling Test. Enhance your skills with flashcards and multiple choice questions, complete with hints and explanations. Prepare effectively for success!

Multiple Choice

How would you handle a multivalue attribute like multiple phone numbers in a relational model?

Explanation:
Handling multivalue attributes in a relational model relies on normalization: store each value as its own row in a related table rather than packing several values into one column. The best approach is to create a child table that carries a foreign key to the parent and a single value column for the phone number. This lets a single person have many phone numbers without duplicating the parent data or forcing nulls, and it keeps data consistent and easy to validate. For example, a Person table with PersonID and Name, and a PhoneNumbers table with PersonID (FK) and PhoneNumber (and optionally PhoneType). Each phone number becomes its own row, tied to the person. In contrast, putting all numbers in one column as a comma-separated list breaks atomicity and makes querying and updating painful; using a separate database is unnecessary and counterproductive; embedding multiple values as separate columns in the parent table fails as you add more numbers and wastes space.

Handling multivalue attributes in a relational model relies on normalization: store each value as its own row in a related table rather than packing several values into one column. The best approach is to create a child table that carries a foreign key to the parent and a single value column for the phone number. This lets a single person have many phone numbers without duplicating the parent data or forcing nulls, and it keeps data consistent and easy to validate. For example, a Person table with PersonID and Name, and a PhoneNumbers table with PersonID (FK) and PhoneNumber (and optionally PhoneType). Each phone number becomes its own row, tied to the person. In contrast, putting all numbers in one column as a comma-separated list breaks atomicity and makes querying and updating painful; using a separate database is unnecessary and counterproductive; embedding multiple values as separate columns in the parent table fails as you add more numbers and wastes space.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy