SQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

o An open-source relational database management system

o MySQL, SQL Server, 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

They are widely used so most web developers will work with one at least a little during their career

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

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

A collection of tables; it defines how the data should be organized

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

What is a table(relation)?

A

A collection of related data

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

What is a row(tuple)?

A

A single data item in a table

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

A domain-specific declarative language used for managing data held in relational database management systems

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

readability

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

*

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 (ascending is default if descending add desc)

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

How do you update rows in a database table?

A

update statement

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

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

A

If you don’t, will update all rows

17
Q

How do you delete rows from a database table?

A

delete statement

18
Q

How do you accidentally delete all rows from a table?

A

Don’t include a where clause

19
Q

What is a foreign key?

A

A column value that links to another table

20
Q

How do you join two SQL tables?

A

join clause

21
Q

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

A

as keyword (aliasing)

22
Q

What are some examples of aggregate functions?

A

count, max, min, avg, sum

23
Q

What is the purpose of a group by clause?

A

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