Help:COAP-3180/hw3: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
 
Line 14: Line 14:
== Homework tasks ==
== Homework tasks ==


=== Part I ===
# Think about a simple web application that needs a database table, i.e. something that is quite similar to homework 1.
# Think about a simple web application that needs a database table, i.e. something that is quite similar to homework 1.
# With a simple text editor create a *.sql file and that includes the necessary SQL commands for creating a table
# With a simple text editor create a *.sql file and that includes the necessary SQL commands for creating a table
Line 20: Line 21:
# Repair errors until it works ...
# Repair errors until it works ...
# Add some data (either use the phpmyadmin interface or write INSERT statements
# Add some data (either use the phpmyadmin interface or write INSERT statements
=== Part II ===
# Create an insert/query interface to your simple table with a php/mysql code generator
# You will have to to demonstrate this application next Monday (week 5)
We suggest to install either:
* http://www.webformgenerator.com/ (Webform generator, less functionality but easier to use.
* http://www.sqlmaestro.com/products/mysql/phpgenerator/ (SQL Maestro PHP Generator)


== Play time ==
== Play time ==

Latest revision as of 00:27, 19 November 2007

Homework 3 - COAP 3180 Fall 2 2007

COAP 3180 Course Page

Summary

Continue the activity started in the classroom, i.e.

  • Define a SQL table with an SQL file
  • Create the table in a MySQL database by importing the file with the SQL instructions

Purpose: Become familiar with SQL table definitions and MySQL database management

Note: You will have to turn in a first version of this homework next Monday (week 4). We then will discuss what you should add to this mini-project.

Homework tasks

Part I

  1. Think about a simple web application that needs a database table, i.e. something that is quite similar to homework 1.
  2. With a simple text editor create a *.sql file and that includes the necessary SQL commands for creating a table
    • Note: Do not try to use all possible SQL datatypes. In most cases INT, VARCHAR, TEXT etc will do.
  3. Import this file into a mySQL database
  4. Repair errors until it works ...
  5. Add some data (either use the phpmyadmin interface or write INSERT statements

Part II

  1. Create an insert/query interface to your simple table with a php/mysql code generator
  2. You will have to to demonstrate this application next Monday (week 5)

We suggest to install either:

Play time

Warning. Be careful with quotes and double quotes.

  • Quotes must be straight (same for double quotes).
 '  = Ok
 ’  = BAD !!!

... So use a real text editor and not a word processor.

Fallback in case you don't have your own database:

Demo 1 example


CREATE TABLE demo1 (
  id int(10) NOT NULL auto_increment,
  login char(10) DEFAULT '' NOT NULL,
  password char(100),
  fullname char(40) DEFAULT '' NOT NULL,
  url char(60) DEFAULT '' NOT NULL,
  food int(11) DEFAULT '0' NOT NULL,
  work int(11) DEFAULT '0' NOT NULL,
  love int(11) DEFAULT '0' NOT NULL,
  leisure int(11) DEFAULT '0' NOT NULL,
  sports int(11) DEFAULT '0' NOT NULL,
  PRIMARY KEY (id),
  KEY login (login)
);

Student database with 2 tables


DROP TABLE IF EXISTS student;
DROP TABLE IF EXISTS exercise;

CREATE TABLE student (
  id int(10) NOT NULL auto_increment,
  name char(40) DEFAULT '' NOT NULL,
  first_name char(40) DEFAULT '' NOT NULL,
  PRIMARY KEY (id)
);

INSERT INTO student VALUES (NULL,'Testeur','Bill');
INSERT INTO student VALUES (NULL,'Testeur','Joe');
INSERT INTO student VALUES (NULL,'Testeuse','Sophie');

CREATE TABLE exercise (
  id int(10) NOT NULL auto_increment,
  title char(40) DEFAULT '' NOT NULL,
  student_id int(10) NOT NULL,
  comments varchar(128),
  url char(60) DEFAULT '' NOT NULL,
  PRIMARY KEY (id),
  KEY student_id (student_id)
);

INSERT INTO exercise VALUES (NULL,"Exercise 1",'1',"small comment",'http://tecfa.unige.ch/');
INSERT INTO exercise VALUES (NULL,"Exercise 2",'1',"no comment",'http://tecfa.unige.ch/');

Reading and links

Reading

Pick one of these. Some articles are presented as multiple pages (!)

Reference

Slides