Week 9 Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a relational database system
Alternatives: MySQL, SQL Server by Microsoft, 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

It’s the most widely used kind of data base so the chances that you’ll run into it as a developer is high
It also 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
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
describes the rules of how tables can be stored
it defines how the data in a relational database should be organized

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

What is a table?

A

a list of rows, each having the same set of attributes aka columns
ex: all students in a “students” table could have “firstName”, “lastName”, and “dateofBirth” attributes

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

What is a row?

A

A collection of attributes for a single record in the table
a record/single instance of data

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 JS?

A

SQL is a declarative language - aka you describe the results you want and the program comes up with its own plan for getting the results
JS is an imperative language – you tell js what to do and how to do it

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 “name of column” from “name of table”

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

use “where” and the criteria

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

consistency and 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 with an integer

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

use * (asterisk)

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

you specify it with order by “column-name” … default is ascending order

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 into “tableName” (“col1”, “col2”, …)
values (‘val1’, ‘val2’, …)

column names are wrapped in “ “
values are wrapped in ‘ ‘

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 inside of parenthesis with each value wrapped in ‘ ‘

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

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

A

You separate the tuples by commas

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

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

A

use returning

  • for all columns or comma-separated list of column names if you want specific ones
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How do you update rows in a database table?

A

update “tableName”
set “column” = ‘value’
where “column” = ‘value’

ex:
update “products”
set “price” = 100
where “productId” = 24

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

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

A

If you don’t, it’ll update every row in the table

21
Q

How do you delete rows from a database table?

A

delete from “table”
where “column” = ‘value”

22
Q

How do you accidentally delete all rows from a table?

A

delete from “tableName”
aka forget a where clause

23
Q

What is a foreign key?

A

A set of attributes (or columns) that refers to the primary key of another table

24
Q

How do you join two SQL tables?

A

select keyword followed by attributes
from keyword followed by name of first table
join keyword followed by name of second table with the using keyword followed by the foreign key in quotes and parentheses
ex:
select *
from “products”
join “suppliers” using (“supplierId”)

25
Q

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

A

Dot notation –> table name in quotes followed by dot and column name in quotes (if you’re renaming column” followed by as keyword followed by the temp name for the column in quotes
ex:
“Products”.”name” as “product”
or
“Products” as “p”

26
Q

What are some examples of aggregate functions?

A

max(), avg(), count(), min(), sum(), every()

27
Q

What is the purpose of a group by clause?

A

places rows into groups/categories
allows you to use aggregates on those groups instead of each row individually

28
Q

What are the three states a Promise can be in?

A
  1. Pending: initial state, neither fulfilled nor rejected
  2. Fulfilled: operation was completed successfully
  3. Rejected: operation failed (error)
29
Q

How do you handle the fulfillment of a Promise?

A

then() method

30
Q

How do you handle the rejection of a Promise?

A

catch() method
OR
use the 2nd parameter in the then() method

31
Q

What is webpack?

A

a tool that lets you bundle your javascript modules
starts from multiple modules and the end result is “fewer files” which is commonly 1 file referred to as a bundle

32
Q

How do you add a devDependency to a package?

A

nmp install <package_name> --save-dev</package_name>

33
Q

What is an npm script?

A

npm scripts are terminal commands that perform a set of actions/allows you to execute repetitive tasks
essentially a command line but with a nickname

34
Q

How do you execute webpack with npm run?

A

use npm run along with the name that you assigned to the webpack in the script

35
Q

What is syntactic sugar?

A

Syntax within a language that is designed to make things easier to read or to express

36
Q

What is the typeof an ES6 class?

A

function

37
Q

Describe ES6 syntax

A

class keyword followed by option name and curly braces
inside of curly braces are properties and prototype methods that you want inside of the object
ex:
class Student {
constructor(firstName, lastName, subject) {
this.firstName = firstName;
this.lastName = lastName;
this.subject = subject;
}

getFullName() {
const { firstName, lastName } = this;
return ${firstName} ${lastName};
}

getIntroduction() {
const { subject } = this;
const fullName = this.getFullName();
return Hello, my name is ${fullName} and I am studying ${subject}.;
}
}

38
Q

What is refactoring?

A

the process of updating existing code to improve design/structure/implementation of software while keeping the functionality

39
Q

How are ES modules different from CommonJS modules?

A

ES modules are official whereas commonJS are a community effort (browsers do not support common js -> must use tools like webpack to make them work)
ES modules use import/export while commonjs modules use require() / module.exports

40
Q

What kind of modules can webpack support?

A

commonjs, es and amd modules

41
Q

What is react?

A

a javascript library for building user interfaces

42
Q

What is a react element?

A

plain old JS object –> object representation of a virtual DOM node
immutable, has no methods and nothing on the prototype

43
Q

How do you mount a react element to the DOM?

A

render() which is a method of the reactDom object

44
Q

What is Babel?

A

JS compiler
a toolchain that is used to convert ES6 code into a backwards compatible version of JS in current and older browsers

45
Q

What is a plug-in?

A

a customization that you add to an existing piece of software
**adds a specific feature to an existing computer program

46
Q

What is a webpack loader?

A

loaders are transformations that are applied to the source of a module

47
Q

How can you make babel and webpack work together?

A

install babel loader

48
Q

What is jsx?

A

Syntax extension to JS

49
Q

Why must the react object be imported when authorizing JSX in a module?

A

because jsx is syntactic sugar for the react.createElement() function