postgres & sql Flashcards

1
Q

Why do we use databases in Web development?

A

for applications to quickly retrieve or store complex data in an organized fashion and to share data to other users and provide a centralized location for application data.

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

What is PostgreSQL and what are some alternative relational databases?

A

a free open source database Relational Database Management System (RDBMS). some alternatives are MySQL, SQL Server, and Oracle.

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

What are some advantages of learning a relational database?

A

they can store and modify data in a way that makes data corruption as unlikely as possible.

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

What is one way to see if PostgreSQL is running?

A

sudo (super user do) service postgresql status

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

What is a database schema?

A

a collection of tables that defines how the data in relational database should be organized

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

What is a table?

A

Relational databases store data in relations. a collection of objects that are the same shape.

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

What is a row?

A

a table each having the same set of attributes. an object or item

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

What is an attribute and what other names are used to describe them?

A

column, key

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

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

A

its a declarative programming language and you just tell it what you want not how.

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

How do you retrieve specific columns from a database table?

A

by using the select and column names after select in double quotes.

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

How do you filter rows based on some specific criteria?

A

by using the ‘where’ clause and any type of expression and the data type value is surrounded by single quotes only if its a string

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

What are the benefits of formatting your SQL?

A

to make it more readability

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

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

A

use the limit keyword

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

How do you retrieve all columns from a database table?

A

use the * to get all columns

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

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

A

use the order by keyword and column name in double quotes and to get it in descending order use keyword desc after the column name

17
Q

How do you add a row to a SQL table?

18
Q

What is a tuple?

19
Q

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

20
Q

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

21
Q

How do you update rows in a database table?

22
Q

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

23
Q

How do you delete rows from a database table?

24
Q

How do you accidentally delete all rows from a table?

25
What is a foreign key?
a key that references back to the primary key of another table
26
How do you join two SQL tables?
keyword join, table.name, keyword using, and column.name
27
How do you temporarily rename columns or tables in a SQL statement?
using the keyword as
28
What are some examples of aggregate functions?
count(), avg(), sum(), min(), max(), etc
29
What is the purpose of a 'group by' clause?
so you can have everything in a group