PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

a relational database management system (RDBMS), MySQL, SQLite, SQL microsoft, 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

easy to reject “bad” data (half written). Easy to store and modify data in a way that makes data corruption as unlikely as possible, widely use

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, TOP command in terminal.

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

A list of rows each having 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

data to fill each 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

SQL is a declarative programming language -> programmers describe the results they want and the programming environment comes up with its own plan for getting those results.
JavaScript is an imperative programming language -> you tell programming environment what to do and how to do it.

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 “column1”, “column2”, … from

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 “column” = ‘something’

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

easier to read top to bottom than left to right

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 * from database_table

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

sort by 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 into “database_name” (“columnName”, …)
value (‘value1’, …), (‘value##’, …), …

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

What is a tuple?

A

list of value, has order.

17
Q

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

A

value (‘value1’, …), (‘value##’, …), …

18
Q

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

A

insert into ….
value ….
returning *;

19
Q

How do you update rows in a database table?

A

update “table_name”
set “column_name” = ‘new value’
where “column_name” = ‘old value’;

20
Q

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

A

otherwise it update ALL the rows.

21
Q

How do you delete rows from a database table?

A

delete
from “table_name”
where “column_name” = ‘value’
[and ….];

22
Q

How do you accidentally delete all rows from a table?

A

delete
from “table_name”;

23
Q

What is a foreign key?

A

common value[s] (of column) between tables

24
Q

How do you join two SQL tables?

A

select “columnName”
from “table1”
join “table2” using (“foreign key”)
[where …. , limit …, order by ….]

25
How do you temporarily rename columns or tables in a SQL statement?
"table_name"."columnName" as "newName"
26
What are some examples of aggregate functions?
sum(), count(), average()
27
What is the purpose of a group by clause?
group result set into bucket by row(s)
28
What are the three states a Promise can be in?
pending, fulfilled, rejected
29
How do you handle the fulfillment of a Promise?
myPromise.then(value)
30
How do you handle the rejection of a Promise?
myPromise.catch(err)
31