« Assignment 2 | Main | assignment 3 »
February 07, 2005
class 03
missed class 2...
"\" escapes a command in perl. so if you want to use character like $ @ ETC...
don't escape and it will "BARF"
subroutine for perl to receive form in for from html:
################################################
# Takes data from an HTML Form or URL string
################################################
sub input_vars_receive
{ $formData = $ENV{'QUERY_STRING'};
if ($ENV{'REQUEST_METHOD'} eq 'POST')
{ read(STDIN, $formData, $ENV{'CONTENT_LENGTH'});
}
this code allows people post or use the browser line.
persistance:
rewrites to the text field. if you dont the text field will return clear...
fix text
redo code
environment tags...
MySQL
chris' class note's
relational database
Tableis made up of:
columns: fields
rows: entries
if a field set is constant one can create a new table to be called into other table.
one to many relationship Like a book one book many pages, birth place,
Many to many relationship for example an album can thought of a part of many styles, can be called a linking table.
" ' " is MySQL's escape character command
insert add
update change
"LIKE"
#
Week 3: Database Design, MySQL, and the SQL Language - Part 1
Topics:
# Introduction to Databases
# Relationship Modeling
# Using PhpMyAdmin To Create Your First Table
# MySQL Data Types
# Basic SQL Commands
Resources:
# Class #3 Notes
# PhpMyAdmin Database Tool
Weekly Assignment:
The basis of this week's assignment is to create and manipulate a table of your own creation, but also to show what you did and present it in a web page that is created by a Perl script. Thus, all SQL statements that you issue will be documented in your web page, as well as how each statement affected the data in your table. Here are more specific instructions:
* Create a table of your choosing which contains the following columns: an ID column, at least one numeric column (i.e. integer, double, or decimal), at least one string column (i.e. varchar, text, or blob), and at least one date or time column (i.e. date, time, datetime, etc). Show a visual representation of the columns of your table in your Perl-generated web page. You can use the "Print View" link on the PhpMyAdmin "Structure" page and take a snapshot of your table in PhotoShop and present it as an image, or you can cut and paste the HTML from the "Print View" link into your Perl script, or use whatever means necessary to show the structure of your table inside of your Perl-generated web page.
* Using the INSERT statement in the PhpMyAdmin SQL window, create at least 5 records.
* Inside of your Perl-generated web page, list the INSERT statements that were used to create your data set. Then show all records in your table. You can use the "Print View" link on the PhpMyAdmin "Browse" page and take a snapshot of your table in PhotoShop and present it as an image, or you can cut and paste the HTML from the "Print View" link into your Perl script, or use whatever means necessary to show the contents of your table inside of your Perl-generated web page.
* Using the SELECT statement in the PhpMyAdmin SQL window, make at three targeted queries. One should be based upon a numeric column (i.e. where id=5), one should be based upon a text query (i.e. where name='Jones') and one should be based upon a datetime column (i.e. where date>'4/1/2001'). Show each query and its respective results inside of your Perl-generated web page.
* Using the UPDATE statement in the PhpMyAdmin SQL window, change at least one of the records in your table. Show the statement and the new contents of your table inside of your Perl-generated web page.
* Using the DELETE statement in the PhpMyAdmin SQL window, remove at least one but not all of the records in your table. Show the statement and the new contents of your table inside of your Perl-generated web page.
Please try to choose your table columns and queries in some sort of coherent fashion. Think of some data in your life that you'd like to organize (address book, the weather, your CDs, etc), and how you might be able to keep track of it, and to obtain interesting results by querying it.
Recommended Reading/Reference:
# Teach Yourself MySQL in 21 Days By Anthony Butcher
Pages 42-46 (Relationship Modeling), 65-83 (Data Types), 109-112 (INSERT), 115-116 (UPDATE), 128-134 (SELECT), 151 (DELETE)
Posted by dimitri at February 7, 2005 03:24 PM