Datasheet

11
Chapter 1: Introduction to PHP and MySQL
The database: Storing data
The core of a Web database application is the database, which is the long-
term memory (I hope more efficient than my long-term memory) that stores
information for the application. A database is an electronic file cabinet that
stores information in an organized manner so that you can find it when
you need it. After all, storing information is pointless if you can’t find it. A
database can be small, with a simple structure — for example, a database
containing the titles and authors’ names of all the books that you own. Or a
database can be huge, with an extremely complex structure — such as the
database that Amazon.com has to hold all its information.
The information that you store in the database comes in many varieties. A
company’s online catalog requires a database to store information about
all the company’s products. A membership Web site requires a database to
store information about members. An employment Web site requires a data-
base (or perhaps two databases) to store information about job openings
and information from résumés. The information that you plan to store could
be similar to information that’s stored by Web sites all over the Internet — or
information that’s unique to your application.
The term database refers to the file or group of files that holds the actual
data. The data is accessed by using a set of programs called a DBMS
(Database Management System). Almost all DBMSs these days are RDBMSs
(Relational Database Management Systems), in which data is organized and
stored in a set of related tables.
In this book, MySQL is the RDBMS used because it’s particularly well suited
for Web sites. MySQL and its advantages are discussed in the section,
“MySQL, My Database,” later in this chapter. You can find out how to orga-
nize and design a MySQL database in Chapter 3.
The application: Moving data
in and out of the database
For a database to be useful, you need to be able to move data into and out of
it. Programs are your tools for this because they interact with the database
to store and retrieve data. A program connects to the database and makes
a request: “Take this data and store it in the specified location.” Another
program makes the request: “Find the specified data and give it to me.” The
application programs that interact with the database run when the user inter-
acts with the Web page. For instance, when the user clicks the submit button
after filling in a Web form, a program processes the information in the form
and stores it in a database.
05_527580-ch01.indd 1105_527580-ch01.indd 11 11/3/09 8:50 PM11/3/09 8:50 PM