Answer these Check for Understanding questions as you work through the assignments.
- What is a database?
- Means of storing, fetching, calculating, and sorting data
- 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.
- What is SQLite3?
- A database engine used to create tables with data
- What is a Table?
- Related data that is organized according to categories, using rows and columns
- What is a primary key?
- A column or a group of columns that uniquely identifies each row in a table
- 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
- 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
- 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
- How can you limit which rows you select from a table?
- By specifying a condition that must be met using WHERE
- 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
- How can you sort your output from a SQL statement?
order
allows you to sort the output data in descending or ascending order
- 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
- What is an aggregate function?
- Performs a calculation on data, such as count and sum
- 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
- What does the
group
statement do?- Groups data/values according to a specifed column
- 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
- Combining the
Copy and Paste the link to your Task Manager repo here: https://github.com/aperezsantos/task_manager
- Define CRUD.
- CRUD stands for Create, Read, Update, and Delete, and are functions used by applications to manipulate data within databases
- 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
- What three files would you need to create/modify for a Rails application to respond to a
GET
request to/tasks
, assuming you have aTask
model.- routes in configuration, task_controller in controllers, html file in views/tasks
- 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
- 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
Completed SQL repeat intermission work.