PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
An open source Relational Database Management System (RDBMS); MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation.
What are some advantages of learning a relational database?
Relational databases are widely used and knowing the SQL language is a portable skill that allows you to work with other databases in the future. They are also good for supporting data integrity, they can store and modify data in a way that makes data corruption as unlikely as possible.
What is one way to see if PostgreSQL is running?
top command; sudo service postgresql status
What is a database schema?
A collection of tables; It tells your database how data should be organized
What is a table?
A list of rows with the same set of attributes
What is a row?
Each entry for the table
What is SQL and how is it different from languages like JavaScript?
SQL is a declarative programming language. Instead of telling the code what to do, you describe the results you want.
How do you retrieve specific columns from a database table?
select “column”
How do you filter rows based on some specific criteria?
where clause
What are the benefits of formatting your SQL?
Readability
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 clause
How do you retrieve all columns from a database table?
asterisk
How do you control the sort order of a result set?
order by “column”; desc if you want it in descending order
How do you add a row to a SQL table?
insert statement
What is a tuple?
a list of values
How do you add multiple rows to a SQL table at once?
use a comma after each entry for values
How do you get back the row being inserted into a table without a separate select statement?
returning clause
How do you update rows in a database table?
update statement
Why is it important to include a where clause in your update statements?
If you don’t, it will update everything in the table
How do you delete rows from a database table?
delete statement and where clause
How do you accidentally delete all rows from a table?
Not specifying a where clause
What is a foreign key?
a key used to link two tables together
How do you join two SQL tables?
join clause “table” using clause (‘column’)
How do you temporarily rename columns or tables in a SQL statement?
as clause
What are some examples of aggregate functions?
count(), sum(), avg()
What is the purpose of a group by clause?
to select specific rows to perform aggregate functions on
What are the three states a Promise can be in?
pending, fulfilled, rejected
How do you handle the fulfillment of a Promise?
then() method
How do you handle the rejection of a Promise?
catch() method