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