postgresql Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

relational database management system, alternative –> Mysql, oracle, sql microsoft

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

data integrity, storing related data, client server model

learn sql –> what everyone uses (sql)

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

sudo service postresql status

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

What is a database schema?

A

schema is a collection of tables, in this case a database with 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

rows and attributes as columns with data

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

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

A

structured query language, it is a declarative language

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

How do you retrieve specific columns from a database table?
How do you filter rows based on some specific criteria?
What are the benefits of formatting your SQL?
What are four comparison operators that can be used in a where clause?
How do you limit the number of rows returned in a result set?
How do you retrieve all columns from a database table?
How do you control the sort order of a result set?

A
  • Select “columns” …
  • Where “column” some operator and what you want it to look like
  • data can be relational
  • = < > !=
  • Limit
  • Select *
  • order by “column” desc
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you add a row to a SQL table?
What is a tuple?
How do you add multiple rows to a SQL table at once?
How do you get back the row being inserted into a table without a separate select statement?

A

insert into “table name” (“columnName”…)
values (‘value’…)
returning *; –> returns row inserted

tuple is a list of values
multiple lines of value rows

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

How do you update rows in a database table?

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

A

UPDATE “table”
SET “column name” = ‘value’
WHERE “column name” = ‘value’

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

How do you delete rows from a database table?

How do you accidentally delete all rows from a table?

A

DELETE from “tableName”

WHERE “columnName” = ‘value’

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

What is a foreign key?
How do you join two SQL tables?
How do you temporarily rename columns or tables in a SQL statement?

A

foreign key is a column that is out of reach of one of the tables and needs to be accessed by using a junction table

join two sql tables using using

SELECT “column Names”
FROM “tableName”

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

What are some examples of aggregate functions?

What is the purpose of a group by clause?

A

sum()
max()
count()

to group rows – colapses it down

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