PostgreSQL/SQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
a powerful, open source object-relational database system. MySQL, Oracle
What are some advantages of learning a relational database?
A quality of many relational databases is that they support good guarantees about data integrity.
Relational databases are arguably the most widely used kind of database.
Good for storing related data
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
A collection of tables that defines how the data in a relational database should be organized
What is a table in terms of relational databases?
AKA relations. A table is a list of rows each having the same set of attributes.
What is a row?
A record within the the data table
What is SQL and how is it different from languages like JavaScript?
SQL is the primary way of interacting with relational databases. It is a declarative language where programmers describe the results and the programming environment comes up with its own plan for getting those results. Whereas, JavaScript is an imperative language where you tell the runtime exactly what to do and how to do it.
How do you retrieve specific columns from a database table?
By using the select statement
How do you retrieve specific columns from a database table?
By using the where clause
What are the benefits of formatting your SQL?
consistent style and readability
What are four comparison operators that can be used in a where clause?
=, !=, >, and <
How do you limit the number of rows returned in a result set?
by using the limit keyword
How do you retrieve all columns from a database table?
by selecting with an * asterisk
How do you control the sort order of a result set?
by using the order by clause
How do you add a row to a SQL table?
by using the insert statement
What is a tuple?
a list of values in SQL
How do you add multiple rows to a SQL table at once?
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?
by using the returning clause with an * asterisk
How do you update rows in a database table?
By using the update statement
Why is it important to include a where clause in your update statements?
If you don’t use a where clause, every row in the table will be updated
How do you delete rows from a database table?
By using the delete statement
How do you accidentally delete all rows from a table?
By not including a where clause
What is a foreign key?
A column in a table that links the table to another table using a mutual identifying value
How do you join two SQL tables?
By using the join clause and identifying a mutual foreign key
How do you temporarily rename columns or tables in a SQL statement?
us the as keyword followed by the desired rename in double quotes
What are some examples of aggregate functions?
avg(), max(), min(), sum(), every()
What is the purpose of a group by clause?
to separate rows into groups to perform aggregate functions on only those groups of rows
What are the three states a Promise can be in?
- pending: initial state, neither fulfilled nor rejected.
- fulfilled: meaning that the operation was completed successfully.
- rejected: meaning that the operation failed.
How do you handle the fulfillment of a Promise?
By using Promise.then
How do you handle the rejection of a Promise?
By using Promise.catch