C H A P T E R 1 1
Data Storage and Retrieval
About Data Storage on Newton Devices
Querying for Indexed Values
Queries can retrieve items according to the presence of one or more index keys and
can test key values as well. A query that tests for the presence or value of an index
key is called an index query.
Soups that have single-slot indexes allow queries to use a single index key to select
soup entries. Detailed information is provided in "Querying on Single-Slot
Indexes" beginning on page 11-39.
Soups that have multiple-slot indexes allow queries to use multiple index keys to
select soup entries. Detailed information is provided in "Querying on Multiple-Slot
Indexes" beginning on page 11-47.
Index queries can be based only on slot names for which an index has been generated.
For example, to select entries according to the presence of the
slot, the soup
that receives the
message must be indexed on the
slot. Entries not
slot are not included in the set of entries referenced by the
Although the entries in the soup are not actually in any particular order themselves,
the index keys associated with them can be sorted in a specific order that is defined
for each NewtonScript data type. Thus, you can envision the contents of an index
as a sequence of entries arranged in key order, as shown in Figure 11-2.
An index provides random access and imposes order
soup shown in Figure 11-2 is indexed on the
slot, which means
that the value of each entry's
slot is used as its index key. Only those entries
slot are included in this index. By sorting key values, the index
imposes order on their corresponding soup entries, which are otherwise unordered.
2 3 4 5
Ascending key order
Descending key order