PostgreSQL + SQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
a Relational Database Management System
uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads
MySQL, SQL, and Oracle SQL
What are some advantages of learning a relational database?
1) let you store relational data– data that connect to one another in some way
2) relational databases support good guarantees about data integrity - developers can set up their database to reject “bad” data and not worried about data being “half written”
3) most widely used kind of database
What is one way to see if PostgreSQL is running?
1) by doing
sudo service postgresql status
to check its status
2) running top command
3) pgweb (the GUI will not work if postgreSQL is not running)
What is a database schema?
its a blueprint of how your data will look
a collection of tables
it defines how the data in a relational database should be organized
What is a table?
a table is where relational databases are stored
a table is a list of rows with the same set of attributes
ex: “customers” table could have “customerId” “firstName” “lastName” “email” “orderNumber”
ex: all students in a “students” table could have “firstName”, “lastName” and “dataOfBirthday” attributes
(attributes are referred to as columns)
What is a row?
a row share the same set of attributes
How do you retrieve specific columns from a database table?
select keyword
list of the attribute name
from the name of the table
How do you filter rows based on some specific criteria?
where clause, attribute name, operator, condition
this expression evaluates to true of false
What are the benefits of formatting your SQL?
make your code more readable
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 follow by maximum number you want
How do you retrieve all columns from a database table?
by using asterisk *
How do you control the sort order of a result set?
order by clause
What is SQL and how is it different from languages like JavaScript?
SQL (similar to CSS and HTML) is a declarative programming language where programmers have to DESCRIBE the results they want and the programming environment (Web browser) comes up with its own plan for getting those results
relational databases interpret SQL and then DYNAMICALLY GENERATE A PLAN OF ACTION to perform the programmer’s commands as efficiently as possible
Whereas JavaScript is an imperative programming language where you tell the JavaScript runtime what to do and HOW TO DO IT
How do you add a row to a SQL table?
insert statement