PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
powerful relational database management system
Redis MangoDB etc
What are some advantages of learning a relational database?
a lot of databases use SQL languages / popular
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
collection of tables -> it sets how the table should be structured
What is a table?
list of a row each having set of attribute
What is a row?
list of datas in table structured
What is SQL and how is it different from languages like JavaScript?
primary way of interacting with relational databases (retrieving, creating, and
manipulating data)
Different from javascript -> imperative langue where programmer tell what to do and how to do
sql -> declarative -> program figures out and describe the results
How do you retrieve specific columns from a database table?
select “column”,
if more than one column. “ “
from “table”
(optional)
where “column” = ‘value’
order by “column” (optional) desc
limit number;
How do you filter rows based on some specific criteria?
where “ “ =, >,
What are the benefits of formatting your SQL?
retrieve the data easily
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 _____
How do you retrieve all columns from a database table?
*
How do you control the sort order of a result set?
order by “column”
if descending order
order by “column” desc
How do you add a row to a SQL table?
sql = `insert into "table" ("column", "column") values ($1, $2) returning *; ` values = [value for $1, value for $2]
db
.query(sql, values)
numbers area automatically generated by app due to avoid duplicate value