Postgres Flashcards
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a free open-source relational database management system
PostgreSQL is a relational database system that is free and open source. Some alternatives are MySQL, SQL Server, and Oracle.
What are some advantages of learning a relational database?
They’re the most widely used type of database.
They support good guarantees about data integrity.
They can store and modify data in a way that makes corruption as unlikely as possible.
They are good for storing related data. They can store and modify data in a way that makes data corruption as unlikely as possible. Also, they are arguably the most widely used kind of database.
Simple Model. Flat
What is one way to see if PostgreSQL is running?
by running ‘sudo service postgresql status’ command
By having a 2nd terminal open and running the top command to monitor the open processes.
sudo service postgresql status / top
- Use the terminal command sudo service postgresql status.
- Check use the terminal top command to see if postgres is running
What is a database schema?
A collection of tables in a database.
What is a table?
A list of rows and columns that store data in relations.
What is a row?
A row is an entry in a table and every row contains the same set of attributes
A single instance of a record within a table.
What is SQL and how is it different from languages like JavaScript?
SQL is a declarative programming language. Instead of telling the code what to do, you describe the results you want.
How do you retrieve specific columns from a database table?
Start with the select keyword.
The select keyword is followed by a comma-separated list of column names, each surrounded by “double quotes”.
e.g: select “firstName”,
“lastName”
By using the select keyword follow by one or more column name wrapped in double quotes.
How do you filter rows based on some specific criteria?
By using the where clause
What are the benefits of formatting your SQL?
For consistent style and readability
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?
asterisk
How do you control the sort order of a result set?
order by “column”; desc if you want it in descending order
Use the order by keyword followed by the column you want to order by in “double quotes.” order will be in ascending order by default - add desc keyword after “specified column” to sort in descending order.
How do you add a row to a SQL table?
insert statement insert into clause followed by the “table” then (column names separated by commas)