A positional collection keeps elements in order and retrieves them by position. Lists and arrays are typical examples; a positional collection of strings is written as [String]. section 3.1
Unlike an index, which retrieves values through keys such as ISBNs or author IDs, a positional collection represents ordered relationships directly. In a library model, a Book can store its authors as an ordered collection of author IDs. section 3.1
Choose the collection representation to fit the use case:
- Use arrays when a simple positional representation is sufficient. section 3.2
- Use linked lists, vectors, sets, or other collection types when their properties better suit the use case. section 3.2
- Keep positional collections distinct from indexes: ordered access uses positions, while keyed access uses string maps. section 3.1
Authors in a Book record
A Book record may contain an authors field such as ["alan-moore", "dave-gibbons"]. The values preserve author order, while the IDs can be resolved through an author index. section 3.2 section 3.1
Figure 3.3 Library management relation model. Dashed lines (e.g., between Book and Author) denote indirect relations, [String] denotes a positional collection of strings, and {Book} denotes an index of Books.
Use the relation model to compare [String] positional collections with {Book} indexes and trace indirect Book–Author relationships. section 3.1
