Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

Chapter 22. Databases

The techniques described in Chapter 21 for storing
and retrieving data kept in files on disk are fine for most purposes,
but sometimes your data calls for the sort of structured storage and
flexible access that only a database can achieve.

To see why, you need to know what a database is. In its simplest
form, a
database
is merely data kept in the form of a table—a grid of rows and
columns, where the information throughout any given column is of a
single datatype. A relational database consists of more than one
table, and REALbasic databases can be relational; but even a
single-table
(flat-file
) database can be
very useful. In fact, even the simplest imaginable flat-file
database—a two-column table—can be useful. Suppose your
application uses a dictionary, a set of word-definition pairs. How
will this information be stored as a file? How will you look up
information in the file? How will you modify information in the file?
These aren’t difficult problems to solve, to be sure; but with
a database, they are solved for you. In this example, one column
consists of words, another consists of definitions; every row is a
word-definition pair. End of problem! REALbasic gives you the
facilities to add word-definition pairs to the file, to delete
word-definition pairs, to see whether a particular word is listed, to
look up the definition for a given word, and so forth.

Actually, REALbasic lets you work with databases in two ways. First, it provides a native database ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.