Lab Notes Nine: Starting the Shopping Cart.

The plan now is this:

What follows is your

A348/A548 LAB ASSIGNMENT NINE

Start by preparing your database by creating three tables, and populating them with data.

burrowww.cs.indiana.edu% mysql -ua348 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3402 to server version: 3.23.27-beta

Type 'help;' or '\h' for help. Type '\c' to clear the buffer

mysql> use a348
Database changed
mysql> show tables like "dgerman_php%";
+-------------------------------+
| Tables_in_a348 (dgerman_php%) |
+-------------------------------+
| dgerman_php_books             |
| dgerman_php_catboo            |
| dgerman_php_categories        |
+-------------------------------+
3 rows in set (0.01 sec)

mysql> describe dgerman_php_categories;
+---------+------------------+------+-----+---------+-------+---------------------------------+
| Field   | Type             | Null | Key | Default | Extra | Privileges                      |
+---------+------------------+------+-----+---------+-------+---------------------------------+
| catid   | int(10) unsigned |      | PRI | 0       |       | select,insert,update,references |
| catname | char(40)         |      |     |         |       | select,insert,update,references |
+---------+------------------+------+-----+---------+-------+---------------------------------+
2 rows in set (0.00 sec)

mysql> select * from dgerman_php_categories;
+-------+-----------------------------+
| catid | catname                     |
+-------+-----------------------------+
|     1 | Mechanics                   |
|     2 | Typesetting                 |
|     3 | Computers                   |
|     4 | Mathematics                 |
|     5 | Scheme                      |
|     6 | Programming                 |
|     7 | Interpreters                |
|     8 | Compilers                   |
|     9 | Games                       |
|    10 | Number Theory               |
|    11 | Perl                        |
|    12 | Object-oriented programming |
|    13 | Semantics                   |
|    14 | Logic                       |
|    15 | Physics                     |
|    16 | Quantum Physics             |
|    17 | General Physics             |
|    18 | Graduate Math               |
|    19 | Cryptography                |
|    20 | Topology                    |
+-------+-----------------------------+
20 rows in set (0.00 sec)

mysql> describe dgerman_php_books;
+-------------+-------------+------+-----+---------+-------+---------------------------------+
| Field       | Type        | Null | Key | Default | Extra | Privileges                      |
+-------------+-------------+------+-----+---------+-------+---------------------------------+
| isbn        | varchar(6)  |      | PRI |         |       | select,insert,update,references |
| author      | varchar(60) | YES  |     | NULL    |       | select,insert,update,references |
| title       | varchar(90) | YES  |     | NULL    |       | select,insert,update,references |
| price       | float(4,2)  |      |     | 0.00    |       | select,insert,update,references |
| description | text        | YES  |     | NULL    |       | select,insert,update,references |
+-------------+-------------+------+-----+---------+-------+---------------------------------+
5 rows in set (0.00 sec)

mysql> select * from dgerman_php_books;
+--------+----------------------------------------------------+-----------------------------------------------------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| isbn   | author                                             | title                                               | price | description                                                                                                                                                                                                                                                                                                          |
+--------+----------------------------------------------------+-----------------------------------------------------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| pes001 | Michael E. Peskin, Daniel V. Schroeder             | An Introduction to Quantum Field Theory             | 65.00 | This book is a clear and comprehensive introduction to quantum field theory, one that develops the subject systematically from its beginnings. The book builds on calculation techniques toward an explanation of the physics of renormalization.                                                                    |
| sus001 | Gerald Jay Sussman, Jack Wisdom, Meinhard E. Mayer | Structure and Interpretation of Classical Mechanics | 60.00 | This textbook takes an innovative approach to the teaching of classical mechanics, emphasizing the development of general but practical intellectual tools to support the analysis of nonlinear Hamiltonian systems. The student actively explores the motion of systems through computer simulation and experiment. |
+--------+----------------------------------------------------+-----------------------------------------------------+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.01 sec)

mysql> describe dgerman_php_catboo;
+-------+------------------+------+-----+---------+-------+---------------------------------+
| Field | Type             | Null | Key | Default | Extra | Privileges                      |
+-------+------------------+------+-----+---------+-------+---------------------------------+
| isbn  | char(6)          |      | PRI |         |       | select,insert,update,references |
| catid | int(10) unsigned |      | PRI | 0       |       | select,insert,update,references |
+-------+------------------+------+-----+---------+-------+---------------------------------+
2 rows in set (0.00 sec)

mysql> select * from dgerman_php_catboo;
+--------+-------+
| isbn   | catid |
+--------+-------+
| fey001 |     1 |
| sus001 |     1 |
| dek003 |     2 |
| dek003 |     3 |
| gkp001 |     3 |
| hpb001 |     3 |
| con002 |     4 |
| dek003 |     4 |
| gkp001 |     4 |
| hpb001 |     4 |
| kob001 |     4 |
| mun001 |     4 |
| fri001 |     5 |
| fri002 |     5 |
| con001 |     6 |
| fri001 |     6 |
| fri002 |     6 |
| hpb001 |     6 |
| fri001 |     7 |
| fri002 |     7 |
| fri001 |     8 |
| con002 |     9 |
| fri002 |     9 |
| con002 |    10 |
| kob001 |    10 |
| con001 |    11 |
| con001 |    12 |
| fri001 |    12 |
| hpb001 |    13 |
| hpb001 |    14 |
| fey001 |    15 |
| pes001 |    15 |
| sus001 |    15 |
| fey001 |    16 |
| pes001 |    16 |
| fey001 |    17 |
| kob001 |    18 |
| mun001 |    18 |
| kob001 |    19 |
| mun001 |    20 |
+--------+-------+
40 rows in set (0.01 sec)

mysql> exit
Bye
burrowww.cs.indiana.edu% exit
burrowww.cs.indiana.edu% 
Great.

Now that you have these let's think for a moment what you will be doing with them. You will be using SQL to retrieve information from these tables. Perhaps just to remember that there is a comprehensive SQL review available (that was posted a week ago) would be reassuring enough.

So let's put together the program.

Or, at least, let's get started.

Dedicate a place to the scripts for this lab.

I suppose ~/apache/apache_1.3.20/htdocs/lab9 is good enough.

Then create this file in it.

Then add whatever the document above takes you (through its links) to it.

The link above completely documents the first aspect of the program.

So it basically offers the following structure:

Every arrow means "is called by".

Backwars, obviously, it means "is called by.

Notice there's only one file, but 8 (eight, not nine) functions.

Your task is: to get this done.

Here's my version of it.

Notice that two things are missing:

But all categories are retrieved from the right table.

The full shopping cart is coming tomorrow, in the same format as today's.

So this is your

A348/A548 LAB ASSIGNMENT NINE

As an UNDERGRADUATE

Implement all of the above.

As a GRADUATE

Implement the show category screen.

(Link takes you to Oct 16 lecture notes that contain the code for that).

The CREATIVITY option

Create your own tables, entries, pictures, categories, etc.

Good luck and let us know if we can help.


Last updated on Oct 24, 2001, by Adrian German for A348/A548