PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
It is a relational database, and alternatives are: MySQL (also free), SQL Server by Microsoft, and Oracle by Oracle Corporation
What are some advantages of learning a relational database?
Use to store related data, maximize data integrity, learn SQL language
What is one way to see if PostgreSQL is running?
Run top, check status with sudo service postgresql status
What is a database schema?
A collection of tables that describe how the DB should be organized
What is a table?
List of rows with same attributes
What is a row?
data with same attributes
What is SQL and how is it different from languages like JavaScript?
structured query language capable of interacting with relational databases. Its a declarative language
How do you retrieve specific columns from a database table?
select keyword
How do you filter rows based on some specific criteria?
where keyword
What are the benefits of formatting your SQL?
increases readability, easier to spot errors
What are four comparison operators that can be used in a where clause?
=, , !=
How do you limit the number of rows returned in a result set?
limit keyword
How do you retrieve all columns from a database table?
*
How do you control the sort order of a result set?
order by
How do you add a row to a SQL table?
insert into “table name” (‘attributes’)
values (‘values’);
What is a tuple?
a list of values is referred to as a tuple
How do you add multiple rows to a SQL table at once?
multiple rows of values
values (‘value’),
‘value’
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 “table name”
set “attribute” = ‘value’
Why is it important to include a where clause in your update statements?
otherwise it will update all rows
How do you delete rows from a database table?
delete from “table name”
How do you accidentally delete all rows from a table?
By not specifying where to delete
What is a foreign key?
a column that links tables
How do you join two SQL tables?
2 joins
How do you temporarily rename columns or tables in a SQL statement?
use “as”
What are some examples of aggregate functions?
max, sum, count, avg, min
What is the purpose of a group by clause?
group rows together and run aggregate functions on these groups
What are the three states a Promise can be in?
pending, fulfilled, rejected
How do you handle the fulfillment of a Promise?
promise.then(), which will execute if and when the promise is fulfilled
How do you handle the rejection of a Promise?
promise.catch(), or then with an error handler