Postgres Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

It is a place to store data. It is an open source relational Database meaning that the data is related to other data that you are storing or the data is interconnected. Redis, MySQL, 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

It is one of the most widely used kind of database. Learning SQL is a transferable skill because a lot of relational databases are driven by the same language. Guarantees data integrity through ACID.
Atomicity consistency isolation and durability.

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

using sudo service postgresql status

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

What does the ACID acronym stand for?

A

Atomicity consistency isolation and durability.

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

Atomicity

A

Each statement is treated as a single unit. Meaning that if one unit fails all the units fail. Meaning there are no half transfers.

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

Consistency

A

transactions can only bring the database from one valid state to another.

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

Isolation

A

The database is in the same state. One transaction does not effect other transactions

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

Durability

A

That once a transaction has been committed it will stay committed even if there is a crash.

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

What is a database schema?

A

schema means plan or organization so its an abstraction that represents the storage model of data in a database. In a relational database schema tables will be interconnected to one another.

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

What is a table?

A

It’s own entity. Would be an object that relates to other objects within the schema. Think Actor film all different tables that represent an object but relate to each other

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

What is a row?

A

a row is a value that is matched with a property which is a column/ attributes.

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

What is SQL and how is it different from languages like JavaScript?

A

Structured Query Language used for managing data in a relational data base. SQL is declarative meaning that you describe the results you want and the database will try to match your input

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

How do you retrieve specific columns from a database table?

A

you use a select statement and grab the attributes/columns from the table that you choose.

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

How do you filter rows based on some specific criteria?

A

you use a where clause with a comparison operator and a value

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

What are the benefits of formatting your SQL?

A

It is easier to read

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

What are four comparison operators that can be used in a where clause?

A

greater than less than not equal to and equal to

17
Q

How do you limit the number of rows returned in a result set?

A

you use the limit clause with a literal integer number

18
Q

How do you retrieve all columns from a database table?

A

use the *

19
Q

How do you control the sort order of a result set?

A

order by clause

20
Q

How do you add a row to a SQL table?

A

you use an insert statement
insert into “table” (name of your columns without the columns that get added automatically)
a tuple

21
Q

What is a tuple?

A

it is a list of values

22
Q

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

A

you add additional tuples with a comma after each besides the last tuple

23
Q

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

A

returning clause with a *

24
Q

How do you update rows in a database table?

A

update keyword table name

set “column name” and then equal = ‘value’

25
Q

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

A

So that it knows where to update or it would update every row in the table

26
Q

How do you delete rows from a database table?

A

delete statement from table

with a where clause

27
Q

How do you accidentally delete all rows from a table?

A

delete from table name with a semicolon not specifying where

28
Q

What is a foreign key?

A

Foreign key is a category that refers to another key in another table. Descendants

29
Q

How do you join two SQL tables?

A

select “a column”
from “a table”
join clause linking the two tables together
using keyword that links them together

30
Q

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

A

You use an alias name and then you have to use an as keyword later on
similar to using a variable

31
Q

What are some examples of aggregate functions?

A

max() avg() count()

expression in the middle

32
Q

What is the purpose of a group by clause?

A

in order to separate rows into groups and perform aggregate functions on those groups of rows