PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
A Relational Database Management System (RDBMS) that uses the SQL language for querying and maintaining the database.
Alternative relational databases include Microsoft SQL Server, MySQL, SQLite, and Oracle.
What are some advantages of learning a relational database?
Relational databases are the most widely used kind of database. Most relational databases are also driven by SQL.
What is one way to see if PostgreSQL is running?
By using the postgresql status command.
(sudo service postgresql status)
What is a database schema?
A collection of tables that define how the data in a relational database should be organized.
What is a table?
A list of rows each having the same set of attributes. (Also referred to as relations)
What is a row?
A row contains attributes (Also referred to as columns)
What is SQL and how is it different from languages like JavaScript?
SQL is how a server can interact with a relational database by retrieving, creating, or manipulating data.
It is a declarative language meaning that developers describe the results they want and the programming environment finds a way to get those results versus saying what to do and how to do it (imperative language).
How do you retrieve specific columns from a database table?
By using a ‘select’ clause followed by a comma separated list of column names in double quotes. Then a ‘from’ clause followed by a table name in double quotes.
How do you filter rows based on some specific criteria?
By using a ‘where’ clause followed by a condition where there is a column name in double quotes, and operator, and the value in single quotes.
What are the benefits of formatting your SQL?
Formatting SQL makes the query easier to understand.
What are four comparison operators that can be used in a where clause?
=, <, > and !=.
How do you limit the number of rows returned in a result set?
By using a ‘limit’ clause followed by a literal integer value.
How do you retrieve all columns from a database table?
By using a ‘select’ clause followed an asterisk (star).
How do you control the sort order of a result set?
By using a ‘order by’ clause followed by the column name and ‘desc’ clause (the order is ascending by default).
How do you add a row to a SQL table?
The ‘insert into’ statement followed by the table name in quotes and a comma separated list of column names in quotes surrounded by parentheses.
Then, the ‘values’ statement followed by a comma separated list of values in single quotes (except numbers) surrounded by parenthesis.