postgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a relational database. Often cited as the most advances open source database of its kind. Other relational databases are MySQL, SQL, and Oracle
What are some advantages of learning a relational database?
Relational databases work around the SQL language so there’s a level of standardization. If you’re storing related data, it’s probably best to use a relational database. They also make data corruption as unlikely as possible.
What is one way to see if PostgreSQL is running?
You can check the top command to see if a PostgreSQL process is running, you can run a Postgres status command, or you can go to your database address and check as well
What is a database schema?
A database schema is a collection of tables A schema defines how the data in a relational database should be organized. Is defined up front
What is a table?
In terms of a relational database, tables are relations and contain a list of rows
What is a row?
A row is a section of a table and each row has the same set of attributes. Each row can be thought of as a record.
What is SQL and how is it different from languages like JavaScript?
SQL is the language used to interact with relational databases. It’s different from JS in that it’s a declarative language. Where programmers describe the results they want as opposed to imperative programming languages where you tell the program what to do and how to do it.
How do you retrieve specific columns from a database table?
you use the SELECT command and specify which column you want and then use the FROM keyword to specify which table it’s from
How do you filter rows based on some specific criteria?
you use the WHERE clause and it needs to have an expression that evaluates to a boolean
What are the benefits of formatting your SQL?
readability
What are four comparison operators than can be used in a WHERE clause?
=, !=, >, <
How do you limit the number of rows returned in a result set?
you use the LIMIT keyword after your selection parameters… followed by the number of rows you want returned
How do you retrieve all columns from a database table?
with the * symbol
How do you control the sort order of a result set?
with the ORDER BY clause
How do you add a row to a SQL table?
The statement begins with the insert keyword
The table to insert into is specified in “ double quotes
The list of columns being inserted is wrapped in () parenthesis
The values being inserted are also wrapped in () in parenthesis in the same order as the columns they belong to… In SQL, a list of values is referred to as a tuple
Text values are wrapped in ‘ single quotes
Numeric values are represented with literal numbers (or decimals if applicable)