postgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS).
alternatives: SQLite, MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation.
What are some advantages of learning a relational database?
- they support good guarantees about data integrity
- 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?
sudo service postgresql status
What is a database schema?
A collection of tables and it defines how the data in a relational database should be organized
What is a table?
a collection of rows that have the same attribute
What is a row?
a single record in a table
What is SQL and how is it different from languages like JavaScript?
Structured Query Language (SQL) lets you access and manipulate databases. it is a declarative language while javascript is imperative
How do you retrieve specific columns from a database table?
select “columnName1”, “columnName2”, …
How do you filter rows based on some specific criteria?
where clause
What are the benefits of formatting your SQL?
easier to read
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 clause
How do you retrieve all columns from a database table?
*
How do you control the sort order of a result set?
order by clause
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?
separate tuples by commas
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 statement
Why is it important to include a where clause in your update statements?
if you don’t, you will update everything
How do you delete rows from a database table?
delete statement
How do you accidentally delete all rows from a table?
if you don’t have a where clause
What is a foreign key?
the value of a column that refers to another column
How do you temporarily rename columns or tables in a SQL statement?
as clause
What are some examples of aggregate functions?
sum, avg, count
What is the purpose of a group by clause?
The GROUP BY clause is a SQL command that is used to group rows that have the same values.