PostgreSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a relational database system that is free and open source. Some alternatives are MySQL, SQL Server, 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

The most widely used kind of database. SQL is a very useful skill to have. Data corruption is very unlikely to happen in a relational 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

By having a 2nd terminal open and running the top command to monitor the open processes.

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

What is a database schema?

A

A schema defines how the data in a relational database is organized.

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

What is a table?

A

A table is a list of rows each having the same set of attributes(columns).

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

What is a row?

A

A row is each individual record or entry that has a set of attributes/columns.

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

SQLis considered a declarative language. Meaning programmers can declare their intent and the output is the desired 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 “name of column”

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 “column” (operator) ‘criteria’

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

Readability. For the business side of things to interpret the data. Consistency.

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

using order by “column”

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 into clause followed by the “table” then (column names separated by commas)

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. The values being wrapped in parenthesis that are in the same order as the columns they belong to.

17
Q

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

A

By using multiple tuples which are separated by commas but still follow the same order as the columns they belong to.

18
Q

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

A

using the returning keyword along with the star/asterisk

19
Q

How do you update rows in a database table?

A

update clause followed by name of table. then the set clause followed by the column that needs updating followed by an equal operator then the value of the desired update

20
Q

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

A

If a where clause is not used, the whole entire table is updated instead of just the targeted/desired data.

21
Q

How do you delete rows from a database table?

A

delete from clause followed by the table

22
Q

How do you accidentally delete all rows from a table?

A

if a where clause is not used, the entire table will be deleted.

23
Q

What is a foreign key?

A

a foreign key is a column that is originally defined/unique in a table and then used in another table as a reference to relate to each table.

24
Q

How do you join two SQL tables?

A

from clause followed by the table name and then the join clause followed by the table name as well and then the using keyword to specify the foreign key.

25
Q

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

A

when selecting columns, the as keyword is used after the name of the columns stated.

26
Q

What are some examples of aggregate functions?

A

max/min, avg, count, sum

27
Q

What is the purpose of a group by clause?

A

It allows the grouping of rows so the aggregate functions can be focused on only them. Instead of focusing on every row in the table.