Skip to content

Instantly share code, notes, and snippets.

View jwashke's full-sized avatar

Josh Washke jwashke

View GitHub Profile
title length tags
Intermediate SQL
90 minutes
SQL

Goals

By the end of this lesson, you will know/be able to:

Week 5 Diagnostic

  • When and why would you rebase?
    • To clean up your commits and get rid of redundant or pointless commits
  • What are the steps to do a basic rebase via the command line?
    • git rebase -i which open atom(on my computer) then choose which commits to delete and which to leaved picked
  • Our cart in Little Shop is not stored in the database. How does its state persist across requests?
    • through an instance variable and session[:cart]
  • Name two objects used in Rails that can be used to track state of the user across requests.
  • sessions and cookies and the database
  • What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?
    • Putting multiple files into one. Like taking several CSS files and putting them all into one CSS file so that only one HTTP request has to be made for a single stylesheet
  • What does it mean to precompile files? What does this have to do with coffeescript and sass files?
    • Sass and CoffeeScript are written in .scss files and .coffee files. They are precompiled which runs thems through an interpreter outputting regular CSS and JavaScript files for the application to use.
  • What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files? alt
  • To minify files is to remove the whitespace from those files. You would want to do this because over a lot of http requests, the size and bandwidth that whitespace is taking is marginal at first but begins to

Setting Group Expectations

Group Member Names: Jared, Josh, Sunny

  1. When are group members available to work together? What hours can each group member work individually? Are there any personal time commitments that need to be discussed? Anytime. Josh needs to catch the last train but thats pretty late.

  2. How will group members communicate? How often will communication happen, and how will open lines of communication be maintained? Private slack channel

Proper commit messages

Seven rules for commit messages

  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters
  • Capitalize the subject line
  • Do not end the subject line with a period
  • Use the imperative mood in the subject line
  • Wrap the body at 72 characters
  • Use the body to explain what and why vs. how Explanation for these rules can be found here

Sass

Whats wrong with CSS?

  1. Its very repetitive
  2. its organization is a mess
  3. changing one thing like the color or font can be a nightmare

How you can dry up your code with just a little bit of Sass

Variables

Models, Databases, Relationships in Rails

What is the difference between a primary key and a foreign key? Where would we find a primary key? What would it be called by default? Where would we find a foreign key? What is the naming convention for a foreign key?

A primary key is the primary unique identifier of a table, a foreign key is the primary key of another table that serves as as the relationship between the two tables. A primary key is generally named id, a foreign key is named othertable_id whith the name of the table the foriegn key links to followed by id.

Write down one example of:

  • a one-to-one relationship.
    • Each car has one license plate and each license plate belongs to one car
  • a one-to-many relationship.
    • A School has many students but each student has only one school
  • a many-to-many relationship.

Sequel

SQL: Declarative RUBY: Object oriented

Object Relational Mappers

Written in an object oriented language and wrapped around a relational database The object classes are mapped to the data tables in the database and the object instances are mapped to individual rows in that database

Ruby ORMs

  • Active Record (used a lot)
  • DataMapper (used a bit)
@jwashke
jwashke / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:23 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
1. Define CRUD.

Create Read Update Delete

2. There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for.
  • GET 'somethings'
    • See a list of all things
  • GET 'somethings/thingid'
    • See a specific thing
  • GET 'somethings/new'
    • See form to create new thing
  • POST 'somethings'