SQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a relational database management system written using a variation of SQL; other examples of relational databases include MySQL, SQL Server, and Oracle
What are some advantages of learning a relational database?
It is used everywhere and is generally better at modeling data
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
A collection of tables in a database; a formal description of how the data should be organized
What is a table?
A collection of rows in a database that all share the same columns(attributes)
What is a row?
An instance of data containing columns(attributes)
What is SQL and how is it different from languages like JavaScript?
SQL stands for Structured Query Language and is the primary way of interacting with relational databases; it is a declarative language (e.g. HTML and CSS) where the programmer uses pre-built keywords to describe the desired result, as opposed to a imperative language (e.g. JavaScript) where the programmer tells the program what to do and how to do it
How do you retrieve specific columns from a database table?
select “column”,
“column”,
…
from “table”
How do you filter rows based on some specific criteria?
where “attribute” = criteria
What are the benefits of formatting your SQL?
It makes it easier to read
What are four comparison operators that can be used in a where clause?
=, !=, >, ‘less than sign’
How do you limit the number of rows returned in a result set?
limit number
How do you retrieve all columns from a database table?
select *
How do you control the sort order of a result set?
order by “attribute” [desc]
How do you add a row to a SQL table?
insert into “table” (“attribute1”, “attribute2”, …)
values (“value1”, “value2”, …)