CSCI 189 - Assignment 5 Lab

The Problem set for this assignment is due 5:00pm October 25.

Start Haskell by following the same procedure that you used in earlier labs.

  1. Open the file http://www.bowdoin.edu/~allen/courses/cs189/Asst5/Asst5.lhs from a Web browser and save this file as Asst5.lhs (do not append the .txt suffix) on the Desktop.
  2. Open the file http://www.bowdoin.edu/~allen/courses/cs189/Asst5/Set.lhs from a Web browser and save this file as Set.lhs (do not append the .txt suffix) on the Desktop.
  3. Open two windows:

    (a) A Unix "Shell" where you can run Haskell programs: select Macintosh HD -> Applications -> Utilities -> Terminal

    (b) A text editor where you can edit Haskell programs: select Macintosh HD -> Applications -> TextEdit

  4. Line up these two window side by side so that you can see them both.
  5. Now switch to the right-hand window and open the tutorial lab exercise for this assignment by selecting File -> Open -> Asst5.lhs The following text should appear in that window.

    ---------------------------------------------------------
    Exploring Properties of Sets and Relations with Haskell
    Allen Tucker
    January 2004
    ---------------------------------------------------------

    > module Asst5 where

    > import Set

    The properties of sets and relations can be explored with the help of Haskell. Due to the limitations of the keyboard, some set operators (such as "intersection") have to be typed using two characters rather than one. Here is a brief summary of the differences in set notation between your book and Haskell.

  6. Now switch to the left-hand window and type the following two lines:
    cd Desktop
    hugs

The properties of relations can be explored with the help of Haskell. This tutorial provides an introduction to defining useful functions and examining properties of sets in Haskell.

Starting SQL in the Lab

  1. Open the file http://www.bowdoin.edu/~allen/courses/cs189/Asst5/OurClass.sql from a Web browser and save this file as OurClass.sql (do not append the .txt suffix) on the Desktop.
  2. Open two windows:

    (a) A Unix "Shell" where you can run Haskell programs: select Macintosh HD -> Applications -> Utilities -> Terminal

    (b) A text editor where you can edit Haskell programs: select Macintosh HD -> Applications -> TextEdit

  3. Line up these two window side by side so that you can see them both.
  4. Now switch to the right-hand window and open the tutorial lab exercise for this assignment by selecting File -> Open -> OurClass.sql. The following text should appear in that window. This text defines the relation OurClass, including and the names of the domains (columns) for this relation.

    USE test;
    DROP TABLE IF EXISTS OurClass;
    CREATE TABLE OurClass (
    Name VARCHAR(8) NOT NULL,
    Class INT,
    Home CHAR(2),
    Calc CHAR(3),
    Prog CHAR(3),
    Career CHAR(12),
    Subject CHAR(12),
    Xwords CHAR(3)
    );
    INSERT INTO OurClass VALUES ('Chris', '2007', 'MA', 'no', 'yes', 'computers', 'cs', 'yes');
    INSERT INTO OurClass VALUES ('Evan', '2007', 'NC', 'hs', 'yes', 'unk', 'cs', 'no');
    INSERT INTO OurClass VALUES ('Jarrett', '2008', 'MD', 'yes', 'yes', 'computers', 'cs', 'yes');
    INSERT INTO OurClass VALUES ('Jason', '2010', 'VA', 'no', 'no', 'pilot', 'aeronautics', 'yes');
    INSERT INTO OurClass VALUES ('Joe', '2008', 'MA', 'yes', 'yes', 'banking', 'econ', 'yes');
    INSERT INTO OurClass VALUES ('John ', '2008', 'NY', 'yes', 'yes', 'unk', 'cs', 'yes');
    INSERT INTO OurClass VALUES ('Karina', '2007', 'NY', 'yes', 'no', 'unk', 'anthro', 'no');
    INSERT INTO OurClass VALUES ('Kate', '2006', 'ME', 'hs', 'no', 'unk', 'english', 'yes');
    INSERT INTO OurClass VALUES ('Matt', '2009', 'MA', 'hs', 'no', 'business', 'unk', 'yes');
    INSERT INTO OurClass VALUES ('Nolan', '2008', 'CA', 'yes', 'yes', 'computers', 'cs', 'yes');

  5. Now switch to the left-hand window and type the following two lines:
      cd Desktop
      mysql < OurClass.sql
  6. When the prompt mysql> appears, type the following commands to get started:
      mysql> use test;
      mysql> select * from OurClass;
  7. Now refer to pages 6-8 in the Assignment 5 problem set to exercise other SQL commands.