PostgresSQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

relational database system/digital database based on the relational model of data/object-relational database management system
MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation.

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

easy to store related data
they support good guarantees about data integrity. They can store and modify data in a way that makes data corruption as unlikely as possible.
categorizing, ease of use, accuracy, commonly used
multiple users can access

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

top command
pgweb and the local server port
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

design that represents the storage of your data in a database.
A schema defines how the data in a relational database should be organized in tables

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. where relational data is stored

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

What is a row?

A

a record in that spreadsheet with the same set of attributes

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 to interact with databases

it is a declarative language like HTML and CSS so the programmer has to describe their 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 statement
select “name”,
double quotes

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

where “category” = ‘cleaning’;

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 more readable and easy to use

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
limit 1;
integer maximum

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 * ‘star’

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 then optional desc

default asc`

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 statement is a means of adding rows to a table
insert into “products” (“name”, “description”, “price”, “category”)
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’);

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

that is being inserted into a db

17
Q

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

A

by 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

returning clause

19
Q

How do you update rows in a database table?

A

update statement
set clause
where clause

20
Q

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

A

where clause in your update statements to only target specific

21
Q

How do you delete rows from a database table?

A

using the delete from statement

22
Q

How do you accidentally delete all rows from a table?

A

by not specifying where to delete from

23
Q

What is a foreign key?

A

a column that links between 2 tables

same value

24
Q

How do you join two SQL tables?

A

join statement An SQL join clause is a way of combining data from two different database tables into one result set.

25
Q

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

A

the as keyword

26
Q

What are some examples of aggregate functions?

A

count, average, max, min(), sum(), and every()

27
Q

What is the purpose of a group by clause?

A

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