Postgres Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

a powerful, free, open source Relational Database Management System (RDBMS) MySQL, SQL Server, Oracle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are some advantages of learning a relational database?

A

they support good guarantees about data integrity, store and modify data in a way that makes data corruption as unlikely as possible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status, or top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a database schema?

A

collection of tables

Defines how the data in a relational database should be organized

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a table?

A

relations - where relational databases are store data in a set of rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a row?

A

Having the same set of attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is SQL and how is it different from languages like JavaScript?

A

Structured Query Language (SQL) - primary way of interacting with relational databases - a declarative programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you retrieve specific columns from a database table?

A

Querying a database typically takes the form of a select statement.
select “name”,
“price”
from “products”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you filter rows based on some specific criteria?

A

where “category” = ‘cleaning’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the benefits of formatting your SQL?

A

Consistent style and readability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are four comparison operators that can be used in a where clause?

A

=, < >, !=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you limit the number of rows returned in a result set?

A

limit #

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you retrieve all columns from a database table?

A

Select *

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you control the sort order of a result set?

A

order by “columnName” asc/desc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you add a row to a SQL table?

A

insert statement is a means of adding rows to a table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a tuple?

A

list of values

17
Q

How do you add multiple rows to a SQL table at once?

A

batch inserted into a database table by specifying more than one tuple of values, separated by commas

18
Q

How do you get back the row being inserted into a table without a separate select statement?

A

Returning clause

19
Q

How do you update rows in a database table?

A

update statement followed by set clause

20
Q

Why is it important to include a where clause in your update statements?

A

Only need to update a specific item in the table

If no where clause it would update every row in the table

21
Q

How do you delete rows from a database table?

A

Using a delete statement followed by table name

22
Q

How do you accidentally delete all rows from a table?

A

Delete from “tableName” with nothing else

Need to specify with a where clause

23
Q

What is a foreign key?

A

the one specific column that links one table to another table.

24
Q

How do you join two SQL tables?

A

Using the join clause

25
Q

How do you temporarily rename columns or tables in a SQL statement?

A

Using alias column names

26
Q

What are some examples of aggregate functions?

A

max(), avg(), sum(), count()

27
Q

What is the purpose of a group by clause?

A

separate/cluster rows into groups and perform aggregate functions on those groups of rows