Skip to content

Instantly share code, notes, and snippets.

@jacksonvaldez
Forked from mikedao/b2_intermission_work.md
Last active November 28, 2021 03:55
Show Gist options
  • Select an option

  • Save jacksonvaldez/abbf6757662ace2861a42f5e497edfdb to your computer and use it in GitHub Desktop.

Select an option

Save jacksonvaldez/abbf6757662ace2861a42f5e497edfdb to your computer and use it in GitHub Desktop.
B2 Intermission Work Submission

B2 Intermission Work

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

HTML

  1. What is HTML? HTML is a markup language. This means that it turns content and data into something visual. It describes the structure of a webpage.
  2. What is an HTML element? A string of text that tells the program what piece of content it needs to display
  3. What is an HTML attribute? They provide additional information about an element. Defined inside the element's start tag.
  4. What is the difference between a class and an id? When would you use one vs. the other? A class can be used by multiple elements in html code while an id can only be used by 1.
  5. What HTML would you write to create a form for a new dog with a "name" and an "age"?
<!DOCTYPE html>
<html>
<body>

<h2>Dog Form</h2>

<form action="/action_page.php">
  <label for="name">Name:</label><br>
  <input type="text" id="name" name="name" value="Sprinkles"><br>
  <label for="age">Age:</label><br>
  <input type="text" id="age" name="age" value="4"><br><br>
  <input type="submit" value="Submit">
</form> 
 
</body>
</html>
  1. What are semantic tags? When would you use them over a div? A semantic element clearly describes its meaning to both the browser and the developer. A div is used to create a block element.
  2. Explain what each of the following HTML tags do and when you would use them:
  • <h1>, <h2>, etc.
  • headers
  • <p>
  • pargraphs for a lot of text
  • <body>
  • everything inside the main section of a webpage
  • <a> and the href attribute
  • This tag defines a link that needs to be accessed
  • <img> and the src attribute
  • This tag fetches an image that can be displayed
  • <div>
  • This is a block element that wraps text in a block.
  • <section>
  • This tag splits different components of your webpage into multiple sections.
  • <ul>, <ol>, and <li>
  • These are used to write out lists like bullet points or 1, 2, 3 ordered list
  • <form>
  • Used to create submittable forms where users input data
  • <input>
  • This tag is used to receive an input from a user

CSS

  1. What is CSS? CSS defines the style of a webpage. You can use multiple styles for the same html code
  2. What is a CSS selector? How do you use the ID selector? The class selector? A selector selects the html element you want to style. .classselector {..., #idselector {...
  3. What are the three ways to include CSS in your HTML documents? What are the pros and cons of each? First: External CSS (pros: all styling is in one place, cons: if html needs specific style, you cant define it with a given html element) Second: Internal CSS (pros: if html needs specific styling, you can use this, cons: cant be used for multiple html documents.) Third: Inline CSS (pros: An inline style may be used to apply a unique style for a single element, cons: can only be used on 1 element)
  4. What is the Box Model? Describe each component of the Box Model. The box model is a structure for boxes or rectangles in css. The 4 components are content, padding, border and margin. The padding is the spacing between the content and the border. The margin is the spacing between the border and everything outside it.

SQL

Jumpstart Lab Tutorial

  1. What is a database? A database is just a collection of data that you can read and write from. It does not have any function besides storage

  2. What is SQL? SQL is a language to interact with a database

  3. What is SQLite3? SQLite3 is an interactive CLI that developers use to help them with SQL, similar to pry or irb

  4. What is a Table? Data of rows and columns

  5. What is a primary key? The id of a row of the table being read from

  6. What is a foreign key? The id of a row of a table outside of the one being read from

  7. Explain what each of the following SQL commands do:

  • insert
  • inserts a row of data into a tabke
  • select
  • reads data from a table
  • where
  • paramater for reading data
  • order by
  • another parameter for reading data
  • inner join
  • returns rows based on criteria from multiple tables

PG Exercises

  1. How can you limit which columns you select from a table? limit INT;
  2. How can you limit which rows you select from a table? SELECT column FROM table WHERE boolean
  3. How can you give a selected column a different name in your output? SELECT column AS new_name FROM table
  4. How can you sort your output from a SQL statement? SELECT * FROM table ORDER BY argument
  5. What is joining? When do you need to join? joining is when you are relating data from seperate tables based on a certain column. You need to do this if you need to calculate something that requires data from multiple tables
  6. What is an aggregate function? a function that performs a calculation on a set of values
  7. List three aggregate functions and what they do.
sum: adds up values
count: counts how many rows meet a condition
avg: returns average of a collection of values
  1. What does the group statement do?

  2. How does the group statement relate to aggregates?

Rails Tutorial: Task Manager

  1. Define CRUD. Create, Retrieve, Update, Delete. These are methods to interact with a database
  2. Define MVC. MVC is a very broad structure of a typical web framework. (Model, View, Controller).
  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. app/controllers/tasks_controller.rb app/views/tasks/action_name.html.erb app/models/task.rb config/routes.rb
  4. What are params? Where do they come from? params is information that comes with a request. A good anology: the information the waitress wrote down on their notepad for your sandwich order is the params.
  5. Check out your routes. Why do we need two routes each for creating a new Task and editing an existing Task? different routes are needed to execute different actions of CRUD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment