PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

Postgres is an open source relational database. MySQL, Microsoft SQL, and 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

Web developers will use a database

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 sudo service postgreql start in one terminal and run top in another.

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

What is a database schema?

A

A collect of tables that your data conforms to.

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 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 the database.

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

The language used to interact with relational databases. It is declarative.

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 “blank” from “blank”

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

Makes it easier to find certain rows or columns

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

equal, less than, greater than, 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 followed by number

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 price - (auto ascending)

order by price “price” 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 clause

into ‘table name’

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

Each set of value in parentheses 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 clause ‘table name’

20
Q

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

A

to target a specific row

21
Q

How do you delete rows from a database table?

A

delete clause

22
Q

How do you accidentally delete all rows from a table?

A

delete from ‘table name’

no where clause

23
Q

What is a foreign key?

A

A column in one table that refers to values in another table.

24
Q

How do you join two SQL tables?

A

join clause “tableName” using (“columnName”)

25
Q

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

A

“columnName”.”name” as “tempName”

26
Q

What are some examples of aggregate functions?

A

avg, count, sum, every

27
Q

What is the purpose of a group by clause?

A

Separate rows into groups