PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

An open source Relational Database Management System (RDBMS); MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation.

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

Relational databases are widely used and knowing the SQL language is a portable skill that allows you to work with other databases in the future. They are also good for supporting data integrity, they can 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

top command; sudo service postgresql status

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

What is a database schema?

A

A collection of tables; It tells your database how data 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

A list of rows with the same set of attributes

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

What is a row?

A

Each entry for the table

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

SQL is a declarative programming language. Instead of telling the code what to do, you describe the results you want.

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

select “column”

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 clause

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

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

=, >, =, <=, <> (not equal)

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 clause

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

asterisk

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 “column”; desc if you want it in descending order

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

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

What is a tuple?

A

a list of values

17
Q

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

A

use a comma after each entry for values

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

20
Q

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

A

If you don’t, it will update everything in the table

21
Q

How do you delete rows from a database table?

A

delete statement and where clause

22
Q

How do you accidentally delete all rows from a table?

A

Not specifying a where clause

23
Q

What is a foreign key?

A

a key used to link two tables together

24
Q

How do you join two SQL tables?

A

join clause “table” using clause (‘column’)

25
Q

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

A

as clause

26
Q

What are some examples of aggregate functions?

A

count(), sum(), avg()

27
Q

What is the purpose of a group by clause?

A

to select specific rows to perform aggregate functions on

28
Q

What are the three states a Promise can be in?

A

pending, fulfilled, rejected

29
Q

How do you handle the fulfillment of a Promise?

A

then() method

30
Q

How do you handle the rejection of a Promise?

A

catch() method