postgres Flashcards
What is PostgreSQL and what are some alternative relational databases?
open source relational database management system. MySQL, SQL server by Microsoft, and Oracle.
What are some advantages of learning a relational database?
Full stack web development always involves databases.
What is one way to see if PostgreSQL is running?
running top command on terminal. sudo service postgresql status command
What is a database schema?
a collection of tables. dictates the structure of your data in your database
What is a table?
table is a list of rows, each having the same set of attributes.
What is a row?
single data record within a table for a specific item.
what is pgweb
graphical user interface of postgres server.
What is SQL and how is it different from languages like JavaScript?
SQL is a declarative language and JavaScript is an imperative language.
How do you retrieve specific columns from a database table?
select “name”
How do you filter rows based on some specific criteria?
using the where clause and condition (predicate)
What are the benefits of formatting your SQL?
better readability. Your SQL can get very complex.
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?
select *
How do you control the sort order of a result set?
desc
How do you add a row to a SQL table?
insert into statement
What is a tuple?
a list of values
How do you add multiple rows to a SQL table at once?
you can specify more than one tuple, separated by commas.
How do you get back the row being inserted into a table without a separate select statement?
returning clause
How do you update rows in a database table?
update statement
Why is it important to include a where clause in your update statements?
because that will modify the every row in the table
How do you delete rows from a database table?
delete from clause
How do you accidentally delete all rows from a table?
without using where clause
why does update or delete statements not work?
foreign key constraint
What is a foreign key?
columns that have the same name as columns in other tables. its used to join tables together.
How do you join two SQL tables?
using join clause
How do you temporarily rename columns or tables in a SQL statement?
“tableName”.”columnName” as “tempName” (aliasing)
What are some examples of aggregate functions?
count, sum, avg
What is the purpose of a group by clause?
separate rows into groups and perform aggregate functions on those groups of rows.