Because your model's data management requirements, such as the agent's memory, is more complicated than can be reasonably managed with lists, and you don't want or don't have an external database extension to work from.
You can use breeds of turtles to create both flat and relational databases. NetLogo's built-in WITH operator can be used to query the database. Many-to-one, one-to-many, and many-to-many relationships can be modeled easily.
Breeds and -OWN'd variables form the structure of the database. Breeds fill the role of tables, while the variables -own'd by the breed represent database fields. Each individual turtle is a record in the table that is its breed. Since each turtle is unique, every record automatically gets a unique primary key–the turtle itself. In records that require a foreign key to link to another turtle/record, the foreign key is a reference to the turtle. The with operator is used to select groups of agents/records. This lets us easily do useful things with the database, such as get groups of records, and do indirect lookups.
breed [ customers customer ] ;; customer table breed [ orders order ] ;; orders table breed [ products product ] ;; products table breed [ order-items order-item ] many-to-many foreign-key table customers-own [ name address phone ;; regular variables my-orders ;; will contain the agentset of all this customer's orders ] orders-own [ customer-id ;; contains a ref to the customer order-date ship-date partial? ;; true if some items were "backordered" ] products-own [ name price qty ] order-items-own ;; the items on in an orderlinks products to orders ;; represents a product in an order [ product-id order-id customer-id qty-ordered ;; how many the customer wanted qty-fulfilled ;; how many the customer has gotten unit-price ;; the unit-price at the time the order was placed backordered? ;; true if qty-fullfilled is less than qty-ordered ]
;; list of bargain products let bargain-products-in-stock products with [ price < 1.00 and qty > 0 ]
;; print the total price of each customer's order ask customers [ let total-price sum [ price ] of order-items with [ customer-id = myself ] print (word name " : " total-price) ]
;; Products with insufficient quantity in stock to fullfill all pending orders let backorders products with [ qty < sum [ qty-ordered - qty-fulfilled ] of orders with [ product-id = myself ] ]
;; print the orders for each customer
ask customers
[ print ( word "Customer: " name " (#" who ")" )
let myorders orders with [ customer-id = myself ]
ask myorders
[ print ( word " Order#" who )
let myitems order-items with [ order-id = myself ]
print " item#, name"
ask myitems
[ ask product-id
[ print ( word " #" who ", " name )
]
]
]
]