phpMyAdmin Exercise 2

MySQL Database Management with phpMyAdmin

 

1.  The easiest way to create databases is to browse to your phpMyAdmin page (http://localhost/phpMyAdmin-2.5.1/ if you followed the above steps). On the right hand side of the page is an input box to type the name of your new database.

2.      Let's create a new database called pet_store (figure 5.3)

 


Figure 5.3

 

3.  After that, we'll need to create a table where we will store information. Let's keep track of the animals with an id number (which the database will assign), animal kind (i.e. species - dog,cat, snake, etc), breed (i.e. lab,poodle, etc), quantity and price. This means we will need a table with 5 fields. I will call my table animals. (See figure 5.4)

 


Figure 5.4

 

4.  Enter in the following data and click the Save button to proceed. Figure 5.5 shows us entering the information:

 

Fields

Type

Length/Values

Extra

Unique

id_num

INT

5

auto_increment

X

species

VARCHAR

25

 

 

breed

VARCHAR

25

 

 

quantity

INT

4

 

 

price

FLOAT

6

 

 

 

 

 

 

 

 

 

Figure 5.5

 

5.  Next, we need to insert some data into our table. To do that, click on the insert tab in the middle of the right frame.

6.  Leave the id_num field blank and enter in the following information or create your own. Click on the Go button after you have entered in the following information. Figure 5.6 will show the resulting page (after you click the Go button).

 

species Dog

breed Black Lab

quantity 123

price 89.99

 


Figure 5.6

 

7.  The box at the top left of the main frame will show that the insertion of the data into the table was successful. Also, note that it gives us an id of one. Now you can click on the Browse tab to see the data in the table now. Figure 5.7 shows an image of this screen.

 


Figure 5.7

 

8.      You can enter in as much data as you'd like by clicking on the Insert tab, or you can do a mass entrance of data if you have the fields in a comma separated (or any other non-common character such as : or ;) text file by clicking on the link near the bottom of this page that says Insert data from a textfile into table.

9.  You can always click on the word pet_store at the top of the page to return to the main pet_store database page. You can also click on the word animals to return to the animals table information page. You can also click on the word localhost to return to the very first page you saw in phpMyAdmin. These links are at the top in the right frame and are HIGHLIGHTED in Figure 5.7

 

 

On Your Own Exercise 2

 

1.  Insert more data into your animals table. Insert at least 10 more items into your database. Turn in a print out of your database by browsing your database in phpMyAdmin (to do this, choose the pet_store database from the drop menu on the left hand side of the screen. Then click on the animals link. The click the browse tab).