PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A
  1. Open source relational databases management system

2. SQLlite, MySQL, Microsoft SQL System

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
  1. Everything in web development is based on databases

2. Will basically always be using relational databases in web development

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 command

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 dictate 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 collection of rows that stored data with the same attributes

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

What is a row?

A

A single record in a 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 declarative - the computer figures it out

JavaScript is imperative - the dev writes the machine instructions

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”,
“column”
From “row”

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

By using where “ “ = “ “

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

To lessen complexity

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

Less than, greater than, 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

The 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

The universal * (star)

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 (desc) or (asc) clause

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

The 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 set of parenthesis with a list of data

17
Q

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

A

Value clause, followed by “value” with command and multiple rows would be closed tuples on top of eachother

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

With an update statement

Update “table”
Set “column” = ‘new value’

20
Q

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

A

So you don’t update all the rows

21
Q

How do you delete rows from a database table?

A

Delete key word

Delete from “row”
Where “column” = ‘value’

22
Q

How do you accidentally delete all rows from a table?

A

Delete from “row”

23
Q

What is a foreign key?

A

A value in a column that has same key in another table

24
Q

How do you join two SQL tables?

A

Join clause
Join “table”
Using (shared foreign key)

25
Q

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

A

Aliasing

Select “a”.”firstName”
From “actors” as “c”

26
Q

What are some examples of aggregate functions?

A

Count(), sum(), min(), max()

27
Q

What is the purpose of a group by clause?

A

So you can specify specific rows to order