Occasionally, an attribute might have more than one value. In a prior chapter, for example, I mentioned storing the names of my children:
These are three distinct strings of text. If you had a single attribute called “Children,” how would you store these?
You could simply put them in a simple text attribute, separated by some sort of marker (technically called a delimiter), like this:
- Alec, Gabrielle, Isabella
We discussed this in the chapter on content storage as something called “serialization.” In that instance the system was serializing a complex value into a simple one. In this instance, the human editor is doing the serialization. This the three separate values that a human is manually serializing into one.
This has limitations. If you wanted to work with the names separately, you’d have to retrieve this information, break up the text string on the commas and remove the whitespace. And, of course, you’d have to know in advance the delimiter was a comma, and all the editors would need to agree on this. If someone went rogue and did this –
- Alec | Gabrielle | Isabella
– then we’d have an invalid value. (Actually, we’d technically still have a valid value – since there are no commas, it would deserialize as a single “name” of “Alec | Gabrielle | Isabella”.)
You could, of course create three different attributes:
But this assumes you’re always going to have three children. What if you have four? What if you have 12?