Skip to content

Instantly share code, notes, and snippets.

@benfox1216
Last active January 25, 2020 22:31
Show Gist options
  • Save benfox1216/7e3483116cf9b220a496f138b8d7a5ce to your computer and use it in GitHub Desktop.
Save benfox1216/7e3483116cf9b220a496f138b8d7a5ce to your computer and use it in GitHub Desktop.

B2 Intermission Work

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

HTML

  1. What is HTML?

HTML stands for Hyper Text Markup Language, and it's the type of code read by browsers to display web pages, minus page formatting.

  1. What is an HTML element?

They are code to tell the browser how to display content, using tags.

  1. What is an HTML attribute?

Provides additional information about HTML elements.

  1. What is the difference between a class and an id? When would you use one vs. the other?

A class is for defining attributes that multiple elements may use, while and id is for definiting attributes of a single unique element.

  1. What HTML would you write to create a form for a new dog with a "name" and an "age"?
<html>
<body>

<h2>Add New Dog</h2>

<form>
  Name:<input type="text" name="name">
  <br>
  Age:<input type="text" name="age">
  <br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>
  1. What are semantic tags? When would you use them over a div?

Semantic tags are readable naming conventions for certain elements, and you would use them whenever they describe their purpose accurately. A div may still be used when you want to name the section that semantic tags don't cover.

  1. Explain what each of the following HTML tags do and when you would use them:
  • <h1>, <h2>, etc.

These are headings, with the bigger numbers representing sub-headings.

  • <p>

This denotes a paragraph.

  • <body>

This denotes the displayed elements on a webpage.

  • <a> and the href attribute

This is an element that is a link to another page, with the href defining the address of the page.

  • <img> and the src attribute

This is an image element, with the src defining the source address of the image.

  • <div>

"div" creates a block, and can have various attributes.

  • <section>

This is for a section of the page, and can have articles, or be nested in itself or articles.

  • <ul>, <ol>, and <li>

"ul" denotes an unordered list, "ol" is an unordered list, and "li" is for the elements of the list.

  • <form>

Forms are for accepting input from the user

  • <input>

Input is an element that can take input from the user

CSS

  1. What is CSS?

Stands for Cascading Style Sheets, and it's for styling HTML pages

  1. What is a CSS selector? How do you use the ID selector? The class selector?

The CSS selector determines which element(s) will be affected by the declarations within it. To use the ID selector, add a # before the id, which must match the id attribute of the element you want to apply it to. To use the class selector, use a period before the class name, which must be given as an attribute for the elements you want it to apply to.

  1. What are the three ways to include CSS in your HTML documents? What are the pros and cons of each?

External, which is great when you want to apply the styles defined on multiple pages of a website. Internal, which is great when you only need to apply with styles defined on a single page. Finally, inline, which should only be used when you only want to change a single element, but this would only be used in rare situations, since it mixes content with presentation.

  1. What is the Box Model? Describe each component of the Box Model.

The box model describes the system of multiple boxes that form the total size of an element. This includes the content (text/images), the padding (space between content and border), the border (goes around the padding & content), and the margin (space around the content, padding and border).

SQL

Jumpstart Lab Tutorial

  1. What is a database?

A database is a system of data storage.

  1. What is SQL?

SQL is a language we use to work with databases, such as finding information, or changing the information in the database.

  1. What is SQLite3?

It's a common database engine.

  1. What is a Table?

A table is a system of rows that contain information, with columns that are defined as headers.

  1. What is a primary key?

A primary key is a column that uniquely identifies each row in a table. Each key is never repeated.

  1. What is a foreign key?

A foreign key is a column that references a column in another table (often the primary key).

  1. Explain what each of the following SQL commands do:
  • insert

inserts a row into a table

  • select

Finds information in a database

  • where

Limits the return value to information that matches the value given by the where statement

  • order by

Causes the returned information to be in some sort of given order (default is ascending)

  • inner join

Brings information in from more than one table

PG Exercises

  1. How can you limit which columns you select from a table?

After the select command, you can name the columns you want to be included in the return value

  1. How can you limit which rows you select from a table?

You can use the where statement to define which rows you want returned

  1. How can you give a selected column a different name in your output?

You can use the "as" statement to define what you want the returned column to be named

  1. How can you sort your output from a SQL statement?

To sort, use the "order by" command, which defaults to ascending, but can also be descending

  1. What is joining? When do you need to join?

Joining is for when you need to join information from multiple tables, which is useful for when the information you need is contained in more than one table.

  1. What is an aggregate function?

An aggregate function does a numeric calculation, and returns the calculated value

  1. List three aggregate functions and what they do.

"count" returns the number of values that match the criteria (such as number of rows), "avg" returns the avg of a given set of numbers, and "sum" returns the total sum of a given set of numbers

  1. What does the group statement do?

"group" defines criteria for different values to be included in a calculation

  1. How does the group statement relate to aggregates?

When using an aggregate function, you can use group to have that calculation done multiple times, each one based on different criteria.

Rails Tutorial: Task Manager

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

Copy and Paste the link to your Static Challenge here: https://github.com/benfox1216/static_challenges

Note: I didn't get much done on the static challenge because I got stuck on trying to make the header look perfect, specifically vertically centering the login button. That was my mistake. But the instructions were to timebox it to 2 hrs, so that's what I did. I would be glad to finish the challenge if necessary.

  1. Define CRUD.

CRUD stands for Creat, Read, Update, Destroy. These are the four things you can do with data.

  1. Define MVC.

MVC stands for model view controller. It's an architectural structure for designing applications

  1. 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.

Route, Controller, and View files

  1. What are params? Where do they come from?

Params is an array that contains the information input by the user, and come from that input

  1. Check out your routes. Why do we need two routes each for creating a new Task and editing an existing Task?

One is to GET a form (create or edit), and the other is to take the input and add a new task or edit an existing one.

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