File: sept4.txt Author: Jeff Kinne Contents: plan/notes for the day Questions for next time * why WITH and not just in FROM? * difference between INNER and NATURAL JOIN? Questions on HW3 HW4 - inserting/creating, todo - set up your own database... TODO: people look up DB questions on GRE and classic job interview DB questions, people look for DB advice blogs. Today - more SQL, creating/inserting * HAVING versus WHERE - * see book for sequence of events. - where evaluated first on each row to decide which to include - group them (if there is a group by) - having restricts which groups are in the final result Examples - Earth Impact Database or Food Data. CREATE TABLE meteors( id primary key auto_increment, name as varchar(100), location as varchar(100), lattitude as varchar(100), longitute as varchar(100), diameter as real, age as real, exposed as char(1), drilled as char(1), targetRock as varchar(100), bollideType as varchar(100)); INSERT INTO meteors (name, location) VALUES ('Hello', 'Terre Haute'); ALTER TABLE meteors ADD comments varchar(200); Example - creation of university database. Views... * queries that get run that user has access to. Natural Join bad, instead could do * SELECT course.course_id, title, dept_name, credits, prereq.prereq_id FROM course, prereq WHERE course.course_id = prereq.course_id