Answer these Check for Understanding questions as you work through the assignments.
- What is HTML?
HTML is the standard markup language for Web pages.
- What is an HTML element?
HTML consists of a series of elements. The elements tell the browser how to display the content.
- What is an HTML attribute?
Attributes are used to provide additional information about HTML elements.
- What is the difference between a class and an id? When would you use one vs. the other?
An id attribute is used to define a special style for one special element. A class attribute defines a style for special types of elements. One would decide which to use based on whether it was a single instance or occured multiple times.
- What HTML would you write to create a form for a new dog with a "name" and an "age"?
<form>
<label for="dogname">Dog name:</label><br>
<input type="text" id="dogname" name="dogname"><br>
<label for="dogage">Dog age:</label><br>
<input type="text" id="dogage" name="dogage">
</form>
- What are semantic tags? When would you use them over a
div?
A semantic element describes its meaning to both the browser and the developer. Semantic elements are useful because they allow data to be shared and reused across applications, enterprises, and communities.
- Explain what each of the following HTML tags do and when you would use them:
In general, a browser reads the HTML tags in order to determine how to display content.
-
<h1>,<h2>, etc.These are tags that designate headers of different sizes.
-
<p>Tag for paragraph element.
-
<body>Tag for visible page content.
-
<a>and thehrefattributeTag for a link, and it utilizes the
hrefattribute to hold the link's destination. -
<img>and thesrcattributeTag used to define images, and
srcdesignates the source file. -
<div>This is a block-level element and is used a container for other HTML elements.
-
<section>This tag defines a section in a document. More specifically, "A section is a thematic grouping of content, typically with a heading."
-
<ul>,<ol>, and<li>The first tag defines an unordered list while the second defines an ordered or numbered list. The final tag is used to designate individual items in the list.
-
<form>This tag defines a form that is used to collect user input.
-
<input>The input tag is the most important form element and is paired with a type attribute that defines the buttons and fields in the form.
- What is CSS?
CSS describes how HTML elements are to be displayed on screen, paper, or other media. HTML was not designed to contain tags for formatting a web page, for example designating fonts and colors.
- What is a CSS selector? How do you use the ID selector? The class selector?
The selector points to the HTML element you want to style. The id selector uses the id attribute of an HTML element to select a specific element. The class selector selects HTML elements with specific class attributes.
- What are the three ways to include CSS in your HTML documents? What are the pros and cons of each?
Inline, internal, and external. Inline is used to apple a unique style to a single HTML element. Internal is used to define a style for a single HTML page. And external is used to define the style for many HTML pages. The advantage of external CSS is that you can alter the look of an entire web site by changing a single file. The external style sheet can be written in any text editor.
- What is the Box Model? Describe each component of the Box Model.
All HTML elements can be considered as boxes. The term "box model" is used when talking about design and layout in CSS. It consists of margins, borders, padding, and the actual content.
- What is a database?
Databases are at the core of almost every web application. They are a means of storing, fetching, calculating, and sorting data.
- What is SQL?
SQL stands for Structured Query Langauge. It is a programming language we use to interact with most databases. The most popular SQL-based databases include PostgreSQL, MySQL, Oracle...
- What is SQLite3?
SQLite stores data in a plain-text file. This makes it easy to move, rename, delete, or transfer the database. It is therefore great for experiments and local development, but not for production. SQLite3 is built into MacOS.
- What is a Table?
A table organizes data into rows and columns.
- What is a primary key?
The primary key in a SQL table is automatically assigned a unique ID number whenever a new row is inserted into the table.
- What is a foreign key?
A foreign key is when the primary key from one table is used as a reference in another table.
- Explain what each of the following SQL commands do:
-
insert
This command is simply used to insert data into a table.
-
select
This command is used to find rows in a table.
-
where
This is used to scope down
SELECTqueries, meaning it limits the returned rows to only those matching the attributes specified. -
order by
Output will be in the order it was inserted, unless you use this command specify how you want it ordered.
-
inner join
This command is used to specify how to join data from separate tables into a new table.
Extra Notes on SQL
- Many programmers use intermediary libraries to generate SQL. Essentially these libraries doe a form of metaprogramming.
- SQL is not object-oriented; it is based on relationships.
- Ruby libraries for interacting with databases are called "Object-Relational Mappers." This means they convert the relational data from the database into Ruby objects.
- ActiveRecord (AR) is the dominant player in this arena. It is the default database library for Rails and is powerful.
- Question: What does library mean in this context?
- How can you limit which columns you select from a table?
By specifying the columns using the select command.
- How can you limit which rows you select from a table?
By using select and specifying the specific rows using the where command.
- How can you give a selected column a different name in your output?
By using the as operator.
- How can you sort your output from a SQL statement?
By using the order_by operator.
- What is joining? When do you need to join?
Joining allows you to combine related information from mutliple tables to answer a question.
- What is an aggregate function?
Aggregate functions are used to extract information about whole groups of rows.
- List three aggregate functions and what they do.
- 'count' : selects the rows that fit the given specifications, and then total the number of rows.
- 'sum' : adds together everyting in the column specified
- 'having' : filters the ouput from aggregate functions
- What does the
groupstatement do?
The group statement allows us to easily batch data into groups.
- How does the
groupstatement relate to aggregates?
The group statement batches data and then we are able to run the aggregation function separately for each group.
Copy and Paste the link to your Task Manager repo here: https://github.com/stellakunzang/task_manager
Copy and Paste the link to your Static Challenge here: https://github.com/stellakunzang/static_challenges
- Define CRUD.
Create, Read, Update, and Delete; these are actions the programs we built will be able to carry out.
- Define MVC.
Model View Controller; this is an architectural pattern used by Rails. This helps us create interactive and dynamic websites.
- What three files would you need to create/modify for a Rails application to respond to a
GETrequest to/tasks, assuming you have aTaskmodel.
I don't fully understand what this question is asking for, but here is my best guess:
- config/routes.rb
- app/controllers/welcome_controller.rb
- app/views/welcome/index.html.erb
- What are params? Where do they come from?
The params are :title and :description. They come from user input.
- Check out your routes. Why do we need two routes each for creating a new Task and editing an existing Task?
One route creates the news tasks object and the other reads information from that object into the tasks controller.