Chapter 10. Organizing Information in Databases
It might seem geeky, but databases are a cornerstone of computing. They’re absolutely everywhere—from iTunes’s jukebox feature to Amazon.com’s book listings. Even if you haven’t bought a dedicated database program like FileMaker Pro (Section 10.4), you encounter databases every day in your regular computer work.
“But what is a database?” you’re probably wondering. A database is a computerized information table—a spreadsheet, in essence. If you imagine turning an Excel document into a database, for example, each row in the spreadsheet would correspond to a record (entry) in the database, while each column in the spreadsheet would correspond to a field (specific information in an entry) of the database. Group a bunch of records together, and voila! You have a database.
Note
The example scripts from this chapter can be found on the AppleScript Examples CD (see Sidebar 2.1 for instructions).
Record Notation
In AppleScript, you use the special record data type to store database information, much like how you use the list data type to store ordered sets of information. To create a record in AppleScript, you use this format:
setrecordName
to {fieldName
:fieldData
,otherFieldName
:otherFieldData
, ...}
You’ve already used this notation, although perhaps without knowing it, for the make command’s with properties option. Record notation is useful for far more than just AppleScript commands, though; records are also convenient for storing clusters of ...
Get AppleScript: The Missing Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.