Help:COAP-3180/week3: Difference between revisions
m (using an external editor) |
|||
Line 8: | Line 8: | ||
'''Relational databases: Introduction to SQL (part 1)''': | '''Relational databases: Introduction to SQL (part 1)''': | ||
* Retrieving data | |||
* Definition of SQL tables and use of the PhpMySQL tool | |||
* Relational tables (principles) | * Relational tables (principles) | ||
; Main teaching materials | ; Main teaching materials | ||
Line 35: | Line 35: | ||
; (1) Demo 1 example | ; (1) Demo 1 example | ||
< | <source lang="sql"> | ||
CREATE TABLE demo1 ( | CREATE TABLE demo1 ( | ||
id int(10) NOT NULL auto_increment, | id int(10) NOT NULL auto_increment, | ||
Line 52: | Line 51: | ||
); | ); | ||
</ | </source> | ||
;(2) Student database with 2 tables | ;(2) Student database with 2 tables | ||
< | <source lang="sql"> | ||
DROP TABLE IF EXISTS student; | DROP TABLE IF EXISTS student; | ||
DROP TABLE IF EXISTS exercise; | DROP TABLE IF EXISTS exercise; | ||
Line 84: | Line 82: | ||
INSERT INTO exercise VALUES (NULL,"Exercise 1",'1',"small comment",'http://tecfa.unige.ch/'); | 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/'); | INSERT INTO exercise VALUES (NULL,"Exercise 2",'1',"no comment",'http://tecfa.unige.ch/'); | ||
</source> | |||
</ | |||
==== Classroom activities Wednesday ==== | ==== Classroom activities Wednesday ==== | ||
* Relational databases | * Continue creating a table (if needed) | ||
* | * Relational databases with 2 or 3 tables (simple 1-N and N-N cases) | ||
* Web hosting (discussion) | |||
* The anatomy of Wordpress | * The anatomy of Wordpress | ||
Line 96: | Line 94: | ||
Topic: Database definition (2-3 tables), Details to be announced on Wednesday. | Topic: Database definition (2-3 tables), Details to be announced on Wednesday. | ||
Define an SQL file that will create 2-4 related tables. You can freely choose the application area, but it should somewhat relate to prior homework or the term project. | |||
</source> | |||
Minimal requirements: | |||
* 2 tables min. and 4 tables max. Make sure that the tables are related | |||
* At least 10 fields (for all tables) | |||
* At least 1 integer and 1 varchar (for all tables) | |||
* Each table must define a primary key | |||
The file must include some documentation on top that (1) explains the purpose of this database and of each table and that (2) provides some high-level design elements. | |||
Remark: | |||
* This homework is not related to the term project, but helps you preparing exams | |||
==== Submission Dates ==== | ==== Submission Dates ==== | ||
* This homework is due at start of wed week 4 | * This homework is due at start of wed week 4 | ||
* Students must upload | * Students must upload the SQL file to the worldclassroom (don't forget the documentation inside this file). | ||
* Each homework counts 10% in your global evaluation. The four best homeworks will be taken into account. | * Each homework counts 10% in your global evaluation. The four best homeworks will be taken into account. | ||
==== Evaluation ==== | ==== Evaluation ==== | ||
* See the worldclassroom | |||
=== Teaching materials and further reading=== | === Teaching materials and further reading=== |
Revision as of 19:47, 26 January 2010
Week 3 - COAP 3180
Topics Covered
Portalware configuration (continued):
- discussion of homework 2 if needed
Relational databases: Introduction to SQL (part 1):
- Retrieving data
- Definition of SQL tables and use of the PhpMySQL tool
- Relational tables (principles)
- Main teaching materials
- Slides used: http://tecfa.unige.ch/guides/te/files/mysql-intro.pdf
- Lecture notes (very similar to slides): SQL and MySQL tutorial
Classroom activities
Monday
- Define a table with SQL code
- Learn how to inject SQL code in MySQL Admin (a web application to administer web databases) in order to create databases and tables
- Create a simple 1-table MySQL database with the database administration tool
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.
- (1) 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)
);
- (2) 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/');
Classroom activities Wednesday
- Continue creating a table (if needed)
- Relational databases with 2 or 3 tables (simple 1-N and N-N cases)
- Web hosting (discussion)
- The anatomy of Wordpress
Homework 3
Topic: Database definition (2-3 tables), Details to be announced on Wednesday.
Define an SQL file that will create 2-4 related tables. You can freely choose the application area, but it should somewhat relate to prior homework or the term project.
</source> Minimal requirements:
- 2 tables min. and 4 tables max. Make sure that the tables are related
- At least 10 fields (for all tables)
- At least 1 integer and 1 varchar (for all tables)
- Each table must define a primary key
The file must include some documentation on top that (1) explains the purpose of this database and of each table and that (2) provides some high-level design elements.
Remark:
- This homework is not related to the term project, but helps you preparing exams
Submission Dates
- This homework is due at start of wed week 4
- Students must upload the SQL file to the worldclassroom (don't forget the documentation inside this file).
- Each homework counts 10% in your global evaluation. The four best homeworks will be taken into account.
Evaluation
- See the worldclassroom
Teaching materials and further reading
- Online software
- We shall use MoWes again
- Teaching materials (slides and reading)
- Slides used: http://tecfa.unige.ch/guides/te/files/mysql-intro.pdf
- Lecture notes (very similar to slides): SQL and MySQL tutorial
You probably will have to complete my lecture notes with extra reading. Pick one of the following. (Unfortunately, some of these articles are presented as multiple pages ....)
- Introduction to Structured Query Language: Version 4.11 by James Hoffman. Good bet if you like concise texts.
- Getting Started With SQL by Ted Brockwood, Web developper's journal. Good as first introduction.
- SQLCourse and SQLCourse2
- Introduction to Databases for the Web: Pt. 1 by Selena Sol, database journal (good, but too many distracting ads)