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
-
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 appsBetter 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
Table images: A Tiny Database and Two Extensions to it
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 ofpub/state_person.sql
, followed by queries such asmca_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 theCTRL/D
character at the psql promptSQL
CREATE TABLE
and related commands (e.g.,GRANT
) form the DDL for logical (conceptual) schemaSQL
CREATE VIEW
commands together withCREATE TABLE
and related commands form the DDL for external schemaSimple
SELECT
queriesNext time: more about queries
Introduction to database design
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
Read Introduction to databases and Introduction to SQL SELECT in "text" area; submit at least one reading question by midnight tonight
Questions on other database "text" pages also welcome.Also, read Lab 7 and optionally submit one or more questions using a separate submission of the reading questions form.
HW3 to appear tonight, due tomorrow night
< >