PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
relational DB mgmt system
RDBMS
MySQL
SQL Server for MS
Oracle
What are some advantages of learning a relational database?
short answer: widely used and very powerful
long answer:
once you learn one, you’ve learned them all except for nuances
they support good guarantees about data integrity; minimize data corruption
What is one way to see if PostgreSQL is running?
$ sudo service postgresql status
shortcut: can just run start command again and it won’t do anythin
sudo = (super user do) keyword in terminal that elevates your privileges
service = control a bg service
pgweb
a TOOL to VISUALIZE our DB
**this is not your server
How to access:
In the terminal that was running $top, launch the pgweb PostgreSQL database client by typing $pgweb and pressing enter. You can stop pgweb at any time by pressing $Ctrl + C.
Visit http://localhost:8081 in your web browser. The upper left corner of the UI should say dev.
**MUST STOP SERVER CTRL + C
psql -c ‘\l’
psql = logs into DB (can be used alone)
-c = command
’ \l ‘ = command in a string, [backslash l ] means list
why PostgreSQL?
works will with Node and has built in functionality, esp for array and object
a lot of ppl with Node backend use postgreSQL
What is a database schema?
collection of tables
the instructions to build the tables
What is a table?
data stored in relations
list of rows w/ same set of attributes (columns)
What is a row?
a record
What is SQL and how is it different from languages like JavaScript?
how to interact with DB’s
declarative like HTML and CSS - you tell it what you want and it will give it back to you (order may change) via its own interpretation
How do you retrieve specific columns from a database table?
select “columnName”
from “tableName”
How do you filter rows based on some specific criteria?
where “condition” = ‘keyword’
use logical comparison operators
What are the benefits of formatting your SQL?
cleaner, minimize mistakes, easy to maintain
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 #ofrows