Page 375 - Beginning PHP 5.3
P. 375

12














                                Introducing Databases







                                                    and SQL


                           In the last chapter you learned how your PHP scripts can use external files to store and retrieve
                         data. Although files do a great job in many circumstances, they ’ re pretty inflexible as data storage
                         solutions go. For example, if you need to filter or sort the data retrieved from a file, you have to
                         write your own PHP code to do it. Not only is this tiresome, but if you ’ re working with large sets
                         of data  —  for example, hundreds of thousands of user records  —  your script will probably grind to
                         a halt. Not good if you ’ re hoping to build a popular Web site.

                           Databases are specifically designed to get around this problem. With their capabilities of
                         organization and immaculate record keeping, they ’ re a bit like lending libraries staffed by super -
                           heroes. No more searching for hours through shelves of musty tomes; just a word at the front desk,
                         a blur of blue and red, and the last remaining copy of  Love in the Time of Cholera  appears  —  as if by
                         magic  —  on the desk in front of you.

                           This is the first in a series of three chapters in which you explore databases and learn how you can
                         use them to create powerful, efficient PHP applications. The next chapter shows you how to access
                         data in databases, and Chapter 14 looks at inserting, updating, and deleting data.

                           The aim of this chapter is to get you started with databases. In this chapter you:
                            ❑       Examine the general advantages of using databases rather than files to store your data
                            ❑       Learn about some of the popular databases that you ’ re likely to come across, and how
                                they differ
                            ❑       Examine the idea of relational databases, and explore common concepts of relational
                                databases such as normalization and indexing
                            ❑       Find out how to configure MySQL, a database system that ’ s freely available and widely
                                used with PHP












                                                                                                      9/21/09   9:11:05 AM
          c12.indd   337                                                                              9/21/09   9:11:05 AM
          c12.indd   337
   370   371   372   373   374   375   376   377   378   379   380