PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A
  • Relational Database Management System

- MySQL, SQLite

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
  • Support good guarantees about data integrity
  • Store and modify data in a way that makes data corruption as unlikely as possible
  • Most widely used kind of 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
  • Running the top command and checking to see postgres processes
  • sudo service postgresql status
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

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

What is a table?

A
  • Data stored in relations in relational database

- 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

-A row represents a complete record of a specific data

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 programming language and JavaScript is imperative programming language
  • Programmers describe the result
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 statement

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

-Easy to find

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

-asterisk

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

-insert keyword

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

What is a tuple?

A

-One row

17
Q

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

A

-Specifying more than one tuple of values, separated by commas

18
Q

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

A

-return *

19
Q

How do you update rows in a database table?

A
  • update keyword and set keyword

- include a where clause

20
Q

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

A

-If a where clause is missing, it would update every row in the table

21
Q

How do you delete rows from a database table?

A
  • delete from keyword

- where clause

22
Q

How do you accidentally delete all rows from a table?

A

-Not including the where clause

23
Q

What is a foreign key?

A

-An attribute in a table that refers to the primary key of another table

24
Q

How do you join two SQL tables?

A

-join clause

25
Q

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

A

-Alias column names by using as keyword

26
Q

What are some examples of aggregate functions?

A
  • max()
  • avg()
  • sum()
27
Q

What is the purpose of a group by clause?

A

-To separate rows into groups and perform aggregate functions on those groups