Unit 6: Working with databases; Part 1
You will soon begin to generate dynamic content. This means that the information you display in a webpage will be extracted from a database, an RSS feed, or some other source that may change on a regular basis. As you design your pages, you will often be unaware of what will be displayed on a page, but must design the page layout regardless of what will appear. For example, imagine that you are designing an on-line gradebook. The values for the gradebook will be pulled from a database; your design task will be to create the interface that allows information to be easily displayed, added, updated, and deleted from the gradebook.
Dynamic design requires that you know how to communicate with information sources to store and retrieve information. Today, we will focus on communicating with a database. One way to send or receive information from a database involves using html forms. A form is used to gather information from the user about the type of request that will be sent to the database.
Working with databases can become complex, but for now we will keep it simple. We will learn how to request and how to add/ update information in the database.
- Below is a series of pages that illustrate the most common tasks involved with databases.
Form 5 Update a record
Form 1 Display the entire contents of a database
Form 2 Display a subset of a database
Form 3 Add a record to a database
Form 4 Delete a record from a database
Your first task is to explore the forms. Use each of the forms so you can answer the following questions:
- Find the first and last names of all of the people listed in the database.
- How many people have completed assignment 1? What are their scores?
- Add three records to the database
- Find the primary key (that is, the id) for each of the people you just added to the database-- delete one of those people from the database
- Change the scores for two of the tree people you just added to the database
- Your second task is the activity described in Assignment 5. To complete this activity you must use an interface that allows you to connect to the mySQL database. To do this, I recommend using phpMyAdmin (my preferance) or installing MySQL Query Browser on your computer. All of the PC labs on campus have MySQL Query Browser installed. Here are some instructions on getting stated with phpMyAdmin.