Skip to content

Instantly share code, notes, and snippets.

@aperezsantos
Last active May 2, 2020 11:05
Show Gist options
  • Save aperezsantos/eed9a95c7839cb4f497a1c3c2d3f715e to your computer and use it in GitHub Desktop.
Save aperezsantos/eed9a95c7839cb4f497a1c3c2d3f715e to your computer and use it in GitHub Desktop.
BE Mod 2 Repeat - Intermission Work containing SQL and Task Manager

BE Mod 2 Repeat - Intermission Work

Answer these Check for Understanding questions as you work through the assignments.

SQL

Jumpstart Lab Tutorial

  1. What is a database?
    • Means of storing, fetching, calculating, and sorting data
  2. What is SQL?
    • Structured Query Language is how we interact with most databases by giving instructions to create, modify, or delete tables, find existing data within tables, insert new data, or change data.
  3. What is SQLite3?
    • A database engine used to create tables with data
  4. What is a Table?
    • Related data that is organized according to categories, using rows and columns
  5. What is a primary key?
    • A column or a group of columns that uniquely identifies each row in a table
  6. What is a foreign key?
    • A column or group of columns in one table that refers to the primary key (column or groups of columns) in another table
  7. Explain what each of the following SQL commands do:
  • insert
    • Adds new data to an existing table
  • select
    • Finds data in a table that you want to display
  • where
    • It scopes into the data by specifying what attributes the data should match in order to be displayed
  • order by
    • It specifies which order the data should be displayed, descending or ascending
  • inner join
    • Joins tables based on a specified relationship between data

SQL CFU

  1. How can you limit which columns you select from a table?
    • By specifying the names of the columns you want in your queries using SELECT
  2. How can you limit which rows you select from a table?
    • By specifying a condition that must be met using WHERE
  3. How can you give a selected column a different name in your output?
    • The AS command is used to rename a column or table with an alias
  4. How can you sort your output from a SQL statement?
    • order allows you to sort the output data in descending or ascending order
  5. What is joining? When do you need to join?
    • Joining is the process of returning matching data from two or more tables
    • You would do this when you're comparing tables, and want to access data that matches
  6. What is an aggregate function?
    • Performs a calculation on data, such as count and sum
  7. List three aggregate functions and what they do.
    • Count: counts the rows that meet a specifed condition
    • Sum: calculates the sum of a set of values
    • AVG: calculates the saverage of a set of values
  8. What does the group statement do?
    • Groups data/values according to a specifed column
  9. How does the group statement relate to aggregates?
    • Combining the group statement with aggregates, allows you to further narrow down the scope of data you want

Copy and Paste the link to your Task Manager repo here: https://github.com/aperezsantos/task_manager

  1. Define CRUD.
    • CRUD stands for Create, Read, Update, and Delete, and are functions used by applications to manipulate data within databases
  2. Define MVC.
    • The Model View Controller framework is an architectural pattern that divides how an application functions into three procecess: model, view, and controller
    • The controller handles incoming requests for specific data
    • The model gathers the data requested
    • The view presents the gathered data
  3. What three files would you need to create/modify for a Rails application to respond to a GET request to /tasks, assuming you have a Task model.
    • routes in configuration, task_controller in controllers, html file in views/tasks
  4. What are params? Where do they come from?
    • params or parameters are objects created from the information entered into a form in an application
    • they appear as a nested hash that includes the information sent in through an application form in the form of a key with a value of another hash that match up with the form fields and the information that a user sends in when they submit that form
  5. Check out your routes. Why do we need two routes each for creating a new Task and editing an existing Task?
    • routes speicify what an application should do with a request from a user
    • two routes are necessary when creating and updating because new views are being created as data changes
@aperezsantos
Copy link
Author

Completed Rails Task Manager CRUD functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment