Creating a Database with MySQL

Page One: But First, a Database -->
Page Two: Data Types-->
Page Three: Using phpMyAdmin to create the simple database-->
Page Four: Defining our Database Fields-->
Page Five: Inserting some Data into our Table-->

But First, a Database....

When the great choreographer George Balanchine first came to this country in the 1930’s, his sponsors were eager for him to establish a great American ballet company. Being a wise man, he counseled, "But first, a school…" He knew that he needed a foundation for the company members who would represent the neoclassical style of his now famous New York City Ballet.

Now what can this possibly have to do with databases and dynamic Web sites? Probably not much more than the spinach and Eunuchs analogy of the last article I wrote on PHP and MySQL, but at least there is more artistry involved here. If you can understand that creating a database driven Web site is not an "out-of-box" experience, that even WYSIWYG software tools such as Dreamweaver MX and GoLive need a foundation, then you’re on your way to taking the journey towards creating your first dynamic Web page.

In the configuration article, we learned how to set up Mac OS X so that it can test and run PHP scripts and MySQL databases. There are two more hurdles to cross before we choreograph our first script/database connection, however. First, a database…in this article, we’ll delve into the art of creating databases. We will use the free, UNIX compatible database MySQL in conjunction with phpMyAdmin, a GUI tool.

(The second hurdle is to understand HTML forms. Don’t all arts involve creating form of some kind? So do our database driven Web sites benefit from pouring our content into forms. If you don’t know how to create forms in a Web page, you should also read my forms article, which is about creating forms in Adobe GoLive. The knowledge here will be applicable to any editor you choose to use, however, so don’t be deterred if you don’t use GoLive, or are even a hand coding warrior.)

Declaring our Intentions

Before designing a database, we should think about how it will be used. Let’s pretend we are the administrators of a pet rescue facility. Every day, there are new arrivals at the center, and current residents (we hope) are adopted. Our newly constructed Web site offers a search page for visitors so that they can look for possible pets. There are dogs and cats of various breeds and ages. Each animal has its picture taken with a digital camera, and that picture is displayed as well.

We also need an administration section of the Web site where the records for the animals can be updated right in the browser. Adopted pets can be removed; new arrivals can be entered. This is done through a simple form with an "Update Record" submit button that will later be facilitated with PHP scripting.

But first, a database…in our case, specifically, we’ll use a MySQL database. Our database will contain 8 fields: an ID number for each animal, its species, its breed, its name (if known), its age (if known), its personality, the date the animal entered the facility, and the file name of the picture of the animal. Next-->

Back to Unix Tips Page-->