Home
>>     < >




In-class notes for 01/15/2018

CS 284 (MCA), Interim 2018

  • This morning: Testing and Continuous Integration for Javascript

  • Quiz at 1pm

  • This afternoon: Intro to Databases and Schemas. Assignment for Wednesday will be a homework

Testing and Continuous Integration for Javascript

  • slides

    • Test the code, not the platform

    • In React Native, UI driven by a virtual DOM tree, which can be used for UI tests. For example, find button in DOM tree, call the button-click method, then look at result DOM.

    • "Happy path" - testing for what an app should do.
      "Sad path" -- testing for good ways to fail.

    • npm i[nstall] --save node-fetch

    • npm i --save-dev jest
      better than --save so not shipped with apps

      • Better than --global because doesn't constrain other projects same host.

      • But as a workaround for shell to find jest, enter
        npm i -g jest

      • Running from command line: jest fetchExample.test.js

    • npm test

  • Test-driven development; Continuous Integration; Separation of Concerns; choose function specs that are readily testable


Submitted questions on assignments and technology

Introduction to databases in CS

Features of relational databases

Introduction to SQL

  • Hands-on exercises (for Link machines):

    Setting up password:

    • Download the file I sent you as a file on Link machines named ~/.pgpass

    • % chmod 600 ~/.pgpass

    % psql mca_i18 -h shelob.cs.stolaf.edu
    mca_i18=> set search_path = username,public;
    
    using your St. Olaf username to access your "Postgres schema". Then, enter the commands of pub/state_person.sql, followed by queries such as
    mca_i18=> select * from state;
    mca_i18=> select * from person where state = 'MN';
    mca_i18=> update person set state = 'MN' where pid = 4;
    mca_i18=> select * from person where state = 'MN';
    
    • To exit from psql, enter the two characters \q or the CTRL/D character at the psql prompt

  • SQL CREATE TABLE and related commands (e.g., GRANT) form the DDL for logical (conceptual) schema

  • SQL CREATE VIEW commands together with CREATE TABLE and related commands form the DDL for external schema

  • Simple SELECT queries

    Next time: more about queries

Introduction to database design

  • Schema levels

  • Entity-Relationship diagrams (context: logical and external schemas)

  • Representing ER diagrams as tables

  • Examples:

    • State, person (with state of birth), lives in

    • CS courses, profs, term/section, and offers (ternary relationship)

    • Note: Relationship attributes must be uniquely identified by participating entities.

  • Translating ER diagrams to relational database tables:

    • Entities --> tables

    • Relationships --> tables consisting of keys of the participating entities plus any attributes for that relationship

Looking ahead




< >