PostgreSQL/SQL Flashcards

1
Q

What is PostgreSQL and what are some alternative relational databases?

A

a powerful, open source object-relational database system. MySQL, 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

A quality of many relational databases is that they support good guarantees about data integrity.
Relational databases are arguably the most widely used kind of database.
Good for storing related data

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 that 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 in terms of relational databases?

A

AKA relations. 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

What is a row?

A

A record within the the data 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

SQL is the primary way of interacting with relational databases. It is a declarative language where programmers describe the results and the programming environment comes up with its own plan for getting those results. Whereas, JavaScript is an imperative language where you tell the runtime exactly 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

By using the select statement

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

How do you retrieve specific columns from a database table?

A

By using the 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

consistent style 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

=, !=, >, and <

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

by using the limit keyword

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

by selecting with an * 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

by using the order by clause

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

by using the insert statement

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 in SQL

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

by specifying more than one tuple of values, separated 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

by using the returning clause with an * asterisk

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

By using the update statement

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 use a where clause, every row in the table will be updated

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

How do you delete rows from a database table?

A

By using the delete statement

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

How do you accidentally delete all rows from a table?

A

By not including a where clause

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

What is a foreign key?

A

A column in a table that links the table to another table using a mutual identifying value

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

How do you join two SQL tables?

A

By using the join clause and identifying a mutual foreign key

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

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

A

us the as keyword followed by the desired rename in double quotes

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

What are some examples of aggregate functions?

A

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

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

What is the purpose of a group by clause?

A

to separate rows into groups to perform aggregate functions on only those groups of rows

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

What are the three states a Promise can be in?

A
  • pending: initial state, neither fulfilled nor rejected.
  • fulfilled: meaning that the operation was completed successfully.
  • rejected: meaning that the operation failed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

How do you handle the fulfillment of a Promise?

A

By using Promise.then

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

How do you handle the rejection of a Promise?

A

By using Promise.catch

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

What is Array.prototype.filter useful for?

A
  • creates a new array with all elements that pass the test implemented by the provided function.
  • When you want to take only certain values from an array
32
Q

What is Array.prototype.map useful for?

A

Quickly apply transformations to each element within an array and returning an array with the new elements

33
Q

What is Array.prototype.reduce useful for?

A

For reducing an array down to one element after performing operations on each element relative to its following element

34
Q

What is “syntactic sugar”?

A

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

35
Q

What is the typeof an ES6 class?

A

Function

36
Q

Describe ES6 class syntax.

A
class Something {
	constructor(a,b,c) {
		this.a = a;
		this.b = b; 
		this.c = c;
	}
	prototypeMethod() {
		blah blah blah code
	}
}
37
Q

What is “refactoring”?

A

the process of restructuring existing computer code—changing the factoring—without changing its external behavior

38
Q

What is Webpack?

A

It’s a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.

39
Q

How do you add a devDependency to a package?

A

npm install –save-dev

40
Q

What is an NPM script?

A

a way to bundle common shell commands for a project

41
Q

How do you execute Webpack with npm run?

A

by adding a script command that will run it with the right keyword ex: “build”: “webpack”

42
Q

How are ES Modules different from CommonJS modules?

A
  • Their syntax is even more compact than CommonJS’s.
  • Their structure can be statically analyzed (for static checking, optimization, etc.).
  • Their support for cyclic dependencies is better than CommonJS’s.
  • es6 modules statically called, commonjs are dynamic
  • commonjs use module.exports property
43
Q

What kind of modules can Webpack support?

A
  • ECMAScript modules
  • CommonJS modules
  • AMD modules
  • Assets
  • WebAssembly modules
44
Q

What is React?

A

A component-based JavaScript library for building user interfaces

45
Q

What is a React element?

A

React elements are plain objects where the React DOM takes care of updating the DOM to match the React elements

46
Q

How do you mount a React element to the DOM?

A

ReactDOM.render()

47
Q

What is Babel?

A

Babel is a compiler that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.

48
Q

What is a Plug-in?

A

a software component that adds a specific feature to an existing computer program

49
Q

What is a Webpack loader?

A

transformations that are applied to the source code of a module

50
Q

How can you make Babel and Webpack work together?

A

By installing babel-loader

51
Q

What is JSX?

A

a syntax extension to JavaScript that uses inline markup that looks like HTML and gets transformed to JavaScript

52
Q

Why must the React object be imported when authoring JSX in a module?

A

JSX is just syntactic sugar so when it gets compiled to plain JS the React methods are being used

53
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

install the babel react JSX plugin and webpack

54
Q

What is a React component?

A

Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen. Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

55
Q

How do you define a function component in React?

A

define a component with the first letter of the name being capitalized, with the argument of props

function Welcome(props) { return <h1>Hello, {props.name}</h1>; }

56
Q

How do you mount a component to the DOM?

A

ReactDom.render()

57
Q

What are props in React?

A

arguments passed into React components

58
Q

How do you pass props to a component?

A

By passing the values as attributes when calling the React component

59
Q

How do you write JavaScript expressions in JSX?

A

By wrapping the expressions within curly braces

60
Q

How do you create “class” component in React?

A

extending the class to React.Component

61
Q

How do you access props in a class component?

A

By using this.props

62
Q

What is the purpose of state in React?

A

For containing data or information about the component. A component’s state can change over time; whenever it changes, the component re-renders.

63
Q

How to you pass an event handler to a React element?

A

by passing it inside the JSX element

64
Q

What Array method is commonly used to create a list of React elements?

A

The map method

65
Q

What is the best value to use as a “key” prop when rendering lists?

A

the id of the item

66
Q

What are controlled components?

A

An input form element whose value is controlled by React

67
Q

What two props must you pass to an input for it to be “controlled”?

A

onChange and onSubmit

68
Q

What does express.static() return?

A

A middleware for serving static files

69
Q

What is the local __dirname variable in a Node.js module?

A

The directory name of the current module

70
Q

What does the join() method of Node’s path module do?

A

It joins all provided path segments together with a slash (/) separator in between and returns the new conjoined path

71
Q

What does fetch() return?

A

A Promise that resolves to a Response object

72
Q

What is the default request method used by fetch()?

A

GET

73
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

By including an object with the method property as the second argument when calling fetch

74
Q

When does React call a component’s componentDidMount method?

A

immediately after a component is mounted (inserted into the tree)

75
Q

Name three React.Component lifecycle methods.

A

componentDidMount()
componentDidUpdate()
componentWillUnmount()

76
Q

How do you pass data to a child component?

A

By pass it through props