Chapter 5 — Storing and Sharing Information 83
Creating a Database Structure
Using a professional RDBMS for storage means that structured data can easily be created and
stored. Through queries (using SQL), precise sets of data can be returned and then formatted
into the XML required by a Google Maps application.
Obviously, the precise format of the database created will be entirely dependent on the infor-
mation being stored, but you should be aware of the following tips and hints as you develop
your application:
Longitude and latitude are best represented as floating-point values. Both should be
stored as floating-point values (the FLOATor REALtype in most databases). It is best
to store these two values in individual float fields in your database. Even though the
RDBMS may support limited-precision floating-point values, you should not limit the
precision of the values you want to store; the higher the precision, the more exact you
can be about point placement.
Store other data in appropriate individual fields. Don’t embed the data and the XML
tags in the field data; just store the data and have the application create the surrounding
tags. This also allows the application to change the tags and formatting if necessary to
suit the needs of the Google Maps application.
Use a unique ID against individual records. This makes it easier to join information
together and also to identify the correct row to update or delete.
Structure data according to the information being stored. For example, a list of restau-
rants may be provided in one table with a list of the meals they provide in a separate
table, linked to the original. Don’t create multiple fields to store duplicate information
(that is, meal_type_a,meal_type_b, and so on). Use the relational functionality of
the database to relate the data and create an appropriate XML structure from the com-
pound data.
Although most RDBMSs use SQL — a standard for creating database tables — differences in
the underlying RDBMS can affect the exact statement used to create the table. Listing 5-19
shows the SQL statement to create a table for storing the restaurant data used in earlier exam-
ples in this chapter.
Open Source Databases
Numerous open source databases are available that you can use while developing and deploy-
ing your Google Maps application. Many web host services provide access to a MySQL
database, so it is probably a better solution while developing your application because it will
present the least problems when you deploy.