Databases/postgreSQL Flashcards
What is PostgreSQL?
“Post Gress Queue El”
relational database management system
What are some alternative relational databases?
Examples: MySQL, Amazon Aurora, Google Fusion Tables, Oracle
What are some advantages of learning a relational database?
Most widely used type of database
Good for storing related data
Good for supporting data integrity
Portable skill
What is one way to see if PostgreSQL is running?
top
sudo service postgresql status
What is a relational database?
A digital database based on the relational model of data, where all data is represented in terms of tuples, grouped into relations)
**commonly referred to as “SQL databases” because you usually do work with them using some variation of the SQL language
What is a database schema?
A collection of tables, defines how the data in a relational database should be organized.
**Schema needs to be defined up front, server will make sure any data being written to database conforms to this schema
What is a table?
(AKA relations) a list of rows that each have the same set of attributes
What is a row?
Line of data with values for each attribute
What is SQL and how is it different from languages like JavaScript?
Structured Query Language - primary way of interacting with and managing relational databases (retrieving, creating, and manipulating data in a relational database)
**declarative - describe results wanted and environment comes up with how to get those results
How do you retrieve specific columns from a database table?
select statement:
select “columnName1”,
“columnName2”
from “tableName”;
How do you filter rows based on some specific criteria?
where (clause) “columnName” = ‘specificValue’;
What are the benefits of formatting your SQL?
Easier to read, easier to see what data is being requested
What are four comparison operators that can be used in a where clause?
, <=, =>, =, != (predicate to truthy or falsy)
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?
select *
from “tableName”