postgres Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

open source relational database management system. MySQL, SQL server by Microsoft, 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

Full stack web development always involves databases.

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

running top command on terminal. 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. dictates the structure of your data in your database

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

What is a table?

A

table is 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

single data record within a table for a specific item.

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

what is pgweb

A

graphical user interface of postgres server.

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

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

A

SQL is a declarative language and JavaScript is an imperative language.

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

How do you retrieve specific columns from a database table?

A

select “name”

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

How do you filter rows based on some specific criteria?

A

using the where clause and condition (predicate)

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

What are the benefits of formatting your SQL?

A

better readability. Your SQL can get very complex.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
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
13
Q

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

A

limit clause

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
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
15
Q

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

A

desc

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

How do you add a row to a SQL table?

A

insert into statement

17
Q

What is a tuple?

A

a list of values

18
Q

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

A

you can specify more than one tuple, separated by commas.

19
Q

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

A

returning clause

20
Q

How do you update rows in a database table?

A

update statement

21
Q

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

A

because that will modify the every row in the table

22
Q

How do you delete rows from a database table?

A

delete from clause

23
Q

How do you accidentally delete all rows from a table?

A

without using where clause

24
Q

why does update or delete statements not work?

A

foreign key constraint

25
What is a foreign key?
columns that have the same name as columns in other tables. its used to join tables together.
26
How do you join two SQL tables?
using join clause
27
How do you temporarily rename columns or tables in a SQL statement?
"tableName"."columnName" as "tempName" (aliasing)
28
What are some examples of aggregate functions?
count, sum, avg
29
What is the purpose of a group by clause?
separate rows into groups and perform aggregate functions on those groups of rows.