Sequel/Databases Flashcards
What is SQL and how is it different from languages like JavaScript?
coding language used to interact with databases
How do you retrieve specific columns from a database table?
select
How do you filter rows based on some specific criteria?
where “column” = ‘condition’
What are the benefits of formatting your SQL?
more easily readable
What are four comparison operators that can be used in a where clause?
= < ><= >= <> (not equal)
How do you limit the number of rows returned in a result set?
limit (number);
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
desc keyword after the statement
order by “price” desc
How do you add a row to a SQL table?
insert into “table” (values)
What is a tuple?
In SQL, a list of values is referred to as a tuple.
How do you add multiple rows to a SQL table at once?
Data rows can be batch inserted into a database table by specifying more than one tuple of values, separated by commas.
How do you get back the row being inserted into a table without a separate select statement?
returning *;
How do you update rows in a database table?
update statement
Why is it important to include a where clause in your update statements?
sets a limit to prevent all values from being changed
How do you delete rows from a database table?
delete statement
How do you accidentally delete all rows from a table?
dont include a where statement
What is a foreign key?
a value in a column that can be used to link two tables
How do you join two SQL tables?
select “firstName”,
“lastName”
from “customers”
join “payments” using (“customerId”)
How do you temporarily rename columns or tables in a SQL statement?
aliases
What are some examples of aggregate functions?
Aggregate functions compute a single result from a set of input values. sum() avg()
What is the purpose of a group by clause?
to separate rows into groups and perform aggregate functions on those groups of rows
What are the three states a Promise can be in?
pending, rejected, fulfilled
How do you handle the fulfillment of a Promise?
.then
How do you handle the rejection of a Promise?
.catch
What does fetch() return?
returns a promise containing the response (a Response object).
What is the default request method used by fetch()?
get
How do you specify the request method (GET, POST, etc.) when calling fetch?
with the 2nd parameter (init)
fetch(‘link’, {
method: ‘POST’
}
When does React call a component’s componentDidMount method?
after the first successful render
Name three React.Component lifecycle methods.
constructor render componentdidmount
How do you pass data to a child component?
props
What does express.static() return?
a middleware function
What is the local __dirname variable in a Node.js module?
The directory name of the current module. This is the same as the path.dirname() of the __filename.
It starts with / so it is absolute file path since it starts at the root of the file system
What does the join() method of Node’s path module do?
The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.