PostgreSQL Flashcards
What are some advantages of learning a relational database?
Relation databases are used to store related data and can store and modify that data in a way that makes data corruption as unlikely as possible. They are also widely used - the most popular databases used in most businesses.
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a free, open-source relational database management system (RDBMS). It is its own database server, its own program.
We are simply using the database.
It has a robust feature set, standards compliance, and reliability. Relation databases are used to store related data and can store and modify that data in a way that makes data corruption as unlikely as possible.
Other relational databases include MySQL (also free), SQL Server by Microsoft, and Oracle by Oracle Corporation.
What is one way to see if PostgreSQL is running?
The command sudo service postgresql status.
What is pgweb?
Pgweb is a web-based database browser for PostgreSQL, written in Go and works on OSX, Linux and Windows machines. Main idea behind using Go for backend development is to utilize ability of the compiler to produce zero-dependency binaries for multiple platforms. Pgweb was created as an attempt to build very simple and portable application to work with local or remote PostgreSQL databases.
What is SQL and how is it different from languages like JavaScript?
SQL is the primary way of interacting with relational databases. It is how we CRUD data.
It’s a declarative programming language, different from imperative languages like JS because rather than telling it what to do and how to do it, the developer describes or declares the sought after results, and the database server dynamically generates a plan of action to get those results.
How do you retrieve specific columns from a database table?
Using the ‘select’ keyword followed by a comma delineated list of column names in double quotes.
Will also need to include the ‘from’ keyword and the table you’re retreiving from.
You can optionally add some filtering features with the ‘where’ clause or the ‘order by’ clause.
How do you filter rows based on some specific criteria?
Using the ‘where’ keyword followed by the filter column name, a comparison operator, and the value used to filter in single quotes.
What are the benefits of formatting your SQL?
Legibility and consistent style.
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?
Using the ‘limit’ keyword and a numerical value, not in quotes.
How do you retrieve all columns from a database table?
Using the ‘select’ keyword with an asterisk * (universal operator?)
How do you control the sort order of a result set?
Using the ‘order by’ clause. You can optionally add ‘desc’ to the end for descending order (ascending is default).
How do you add a row to a SQL table?
Using an insert statement followed by the name of the table and a comma delineated list of column names wrapped in parentheses, then below that, the values keyword followed by a comma delineated list of respective values in single quotes wrapped in parentheses. Optionally, you can add a returning keyword to the end to see the inserted data with the autogenerated column data.
What is a tuple?
In SQL, a list of values is referred to as a tuple.
How do you add multiple rows to a SQL table at once?
Entering a comma delineated list of tuples, each wrapped in its own set of parentheses