PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

It is a relational database, and alternatives are: MySQL (also free), 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

Use to store related data, maximize data integrity, learn SQL language

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

Run top, check status with 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 that describe how the DB 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

List of rows with same attributes

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

What is a row?

A

data with same 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 capable of interacting with relational databases. Its a declarative 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

select keyword

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 keyword

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

increases readability, easier to spot errors

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 keyword

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

*

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

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 into “table name” (‘attributes’)

values (‘values’);

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 is referred to as a tuple

17
Q

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

A

multiple rows of values

values (‘value’),
‘value’

18
Q

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

A

returning *;

19
Q

How do you update rows in a database table?

A

update “table name”

set “attribute” = ‘value’

20
Q

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

A

otherwise it will update all rows

21
Q

How do you delete rows from a database table?

A

delete from “table name”

22
Q

How do you accidentally delete all rows from a table?

A

By not specifying where to delete

23
Q

What is a foreign key?

A

a column that links tables

24
Q

How do you join two SQL tables?

A

2 joins

25
Q

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

A

use “as”

26
Q

What are some examples of aggregate functions?

A

max, sum, count, avg, min

27
Q

What is the purpose of a group by clause?

A

group rows together and run aggregate functions on these groups

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

promise.then(), which will execute if and when the promise is fulfilled

30
Q

How do you handle the rejection of a Promise?

A

promise.catch(), or then with an error handler