Chapter 4 Lab
Adding Rows to Database Tables
Make yourself a copy of this CGI script.
- Reads information about a book to be added to the title
table of the Nile database from an
HTML form
- Checks that the values entered into the form are reasonable.
- Connects to the Nile database and INSERTs the new book into the table.
Tasks to Do for this Lab
- Modify the CGI script to add the proper SQL for the INSERT statement.
Solution
Extra for Experts
Reject attempts to INSERT a book that already exists in the table,
i.e. when a book already exists with the same title, price, and edition.
Extra-Extra for Expert-Experts
Modify the HTML form and CGI script to elicit the title_id
from the user instead of by auto-incrementing.
What happens when you try to INSERT a book with
a duplicate title_id?
Extra-Extra-Extra for Expert-Expert-Experts
So far, are we complying with relational database normal form?
If not, how should we modify our schema?
Dan Keller Technical Services © 2000