LFZ Quiz questions (Senior #3) Flashcards

1
Q

(postgres-intro)

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is one of the relational database. Other popular relational databases include MySQL (also free), MariaDB, MongoDB, 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

(postgres-intro)

What are some advantages of learning a relational database?

A

Many problem domains can be modeled well using a relational database. If you are storing related data, then a relational database is probably a good first choice!
This model organizes data into one or more tables (or “relations”) of columns and rows, with a unique key identifying each row.

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

(postgres-intro)

What is one way to see if PostgreSQL is running?

A

We can use a command ‘top’ to see the process of postgres

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

(postgres-database)

What is a database schema?

A

A collection of tables is called a schema. A schema defines how the data in a relational database should be organized. bunch of tables.

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

(postgres-database)

What is a table?

A

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

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

(postgres-database)

What is a row?

A

A row represents a single, implicitly structured data item in a table.
Whereas, Attributes are commonly referred to as columns.

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

(sql-select)

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

A

SQL is Structured Query Language and declarative programming language. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results.

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

(sql-select)

How do you retrieve specific columns from a database table?

A

The select keyword is followed by specific column’s name

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

(sql-select)

How do you filter rows based on some specific criteria?

A

We can use a keyword ‘where’ and “column name” = ‘criteria’

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

(sql-select)

What are the benefits of formatting your SQL?

A

It’s easy to read and alter values.

dynamically generate a plan of action to perform the programmer’s commands as efficiently as possible.

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

(sql-select)

What are four comparison operators that can be used in a where clause?

A

=, , !=, <=, >=, etc

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

(sql-select)

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

A

We can use limit keyword and number

ex) limit 5

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

(sql-select)

How do you retrieve all columns from a database table?

A

select * from “table name”

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

(sql-select)

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

A

We can use order by keyword

ex) order by “column name” desc / asc

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

(sql-insert)

How do you add a row to a SQL table?

A

ex)
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

(sql-insert)

What is a tuple?

A

In SQL, a list of values is referred to as a tuple.

17
Q

(sql-insert)

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

A

Data rows can be batch inserted into a database table by specifying more than one tuple of values, separated by commas.
ex)
insert into “products” (“name”, “description”, “price”, “category”)
values (‘Ostrich Pillow’, ‘Feel comfy and cozy!’, 99, ‘self care’),
(‘Tater Mitts’, ‘Scrub some taters!’, 6, ‘cooking’)
returning *;

18
Q

(sql-update)

How do you update rows in a database table?

A
We can use update, set, where clauses.
ex)
update "products"
   set "price" = 100
 where "productId" = 24;
19
Q

(sql-update)

How do you update rows in a database table?

A
We can use update, set, where clauses.
ex)
update "products"
   set "price" = 100
 where "productId" = 24;
20
Q

(sql-delete)

How do you delete rows from a database table?

A

delete from “products”
where “productId” = 24
returning *;

21
Q

(sql-delete)

How do you accidentally delete all rows from a table?

A

delete from “table name”;

without where statement

22
Q

(sql-delete)

How do you accidentally delete all rows from a table?

A

delete from “table name”;

without where clause

23
Q

(sql-join)

What is a foreign key?

A

Other table’s primary key can be uses as a column attribute to make a relation between two tables.

24
Q

(sql-join)

How do you join two SQL tables?

A

select *
from “products”
join “suppliers” using (“supplierId”);

25
Q

(sql-join)

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

A

We can use “as” clause .

26
Q

(sql-aggregates)

What are some examples of aggregate functions?

A

sum, count, avg, max, min

27
Q

(sql-aggregates)

What is the purpose of a group by clause?

A

It divides rows into groups and applies an aggregate function on each.