PostgresSQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
relational database system/digital database based on the relational model of data/object-relational database management system
MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation.
What are some advantages of learning a relational database?
easy to store related data
they support good guarantees about data integrity. They can store and modify data in a way that makes data corruption as unlikely as possible.
categorizing, ease of use, accuracy, commonly used
multiple users can access
What is one way to see if PostgreSQL is running?
top command
pgweb and the local server port
sudo service postgresql status
What is a database schema?
design that represents the storage of your data in a database.
A schema defines how the data in a relational database should be organized in tables
What is a table?
A table is a list of rows each having the same set of attributes. where relational data is stored
What is a row?
a record in that spreadsheet with the same set of attributes
What is SQL and how is it different from languages like JavaScript?
the language to interact with databases
it is a declarative language like HTML and CSS so the programmer has to describe their desired result
How do you retrieve specific columns from a database table?
select statement
select “name”,
double quotes
How do you filter rows based on some specific criteria?
where clause
where “category” = ‘cleaning’;
What are the benefits of formatting your SQL?
makes it more readable and easy to use
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
limit 1;
integer maximum
How do you retrieve all columns from a database table?
select * ‘star’
How do you control the sort order of a result set?
order by clause then optional desc
default asc`
How do you add a row to a SQL table?
insert statement is a means of adding rows to a table
insert into “products” (“name”, “description”, “price”, “category”)
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’);