PostgreSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL (Structured Query Language) is a powerful, free, open source, Relational Database Management System (RDBMS) that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.
MySQL, SQP Server by Microsoft, and Oracle by Oracle Corporation
What are some advantages of learning a relational database?
They support good guarantees about data integrity. They can store and modify data in a way that makes data corruption as unlikely as possible. Developers can set up their database to reject “bad” data and not worry about data being “half-written”
All relational databases share the same syntax. Data you store can be compacted well. Does not require a complex structure - simple model. Data accuracy and integrity, high security. Flexibility, can combine or update data, joining tables.
What is one way to see if PostgreSQL is running?
sudo service postgresql status
Check top to list currently running processes
What is a database schema?
A collection of tables. A schema defines structure - how the data in a relational database should be organized. In relational databases, you typically have to define your schema up front and the database server will make sure that any data being written to the database conforms to that schema.
What is a database schema?
A collection of tables. A schema defines structure - how the data in a relational database should be organized. In relational databases, you typically have to define your schema up front and the database server will make sure that any data being written to the database conforms to that schema.
What is a table?
Relational databases store data in relations, commonly referred to as tables.
A table is a list of rows each having the same set of attributes .
Tables define what attributes (columns) that each row should have.
What is a row (tuple)?
A single record of data. Each row is an instance of a row type.
What is SQL and how is it different from languages like JavaScript?
SQL (structured query language) is the primary way of interacting with relational databases. It is a powerful way of retrieving, creating, and manipulating data in a relational database.
SQL is a declarative programming language whereas JavaScript is an imperative language where you tell the JavaScript runtime what to do and how to do it. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results.
How do you retrieve specific columns from a database table?
select “column1”,
“column2”
from “table”;
How do you filter rows based on some specific criteria?
select “column1”, “column2” “column3” from “table” where “col-filter” = ‘value’;
What are the benefits of formatting your SQL?
Consistent style and readability
What are four comparison operators that can be used in awhereclause?
= , != , < , >
How do you limit the number of rows returned in a result set?
select “column1”, “column2” from “table” order by “col-order” desc limit 1;
How do you retrieve all columns from a database table?
select *
from “table”;
Order of results is NOT predictable
How do you control the sort order of a result set?
select *
from “table”
order by “column”;
Default sort order is ascending order
Add desc to sort descending order