Our problem is that we cannot tell which invoices belong to which vendors from this file. To solve this
problem with a linked list, we add a pointer field to every record. In this field, we store the address of
some other related record. For example, we place in VENDOR AA’s link field the address of the first invoice
belonging to it. This is RRN7, which is Invoice 110. Then, we make Invoice 110 point to the next
invoice belonging to VENDOR AA, in this case RRN3. This slot holds Invoice 118. To indicate that there
are no more children in the chain, we insert a 0 in the link field for RRN3.
This technique is shown in Figure H-21. If you examine the figure, you will see that a similar set of links
has been used to represent the relationship between VENDOR BB and its invoices. The structure in Figure
H-21 is much easier to modify than is a sequential list of the records. For example, suppose that we
add a new invoice, say number 111, to VENDOR AA. To do this, we just add the record to the file and
insert it into the linked list. Physically, the record can be placed anywhere. But where should it be placed
logically? Usually, the application will have a requirement; for example, children are to be kept in