PostgreSQL/SQL Flashcards
What is PostgreSQL and what are some alternative relational databases?
a powerful, open source object-relational database system. MySQL, Oracle
What are some advantages of learning a relational database?
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
What is one way to see if PostgreSQL is running?
sudo service postgresql status
What is a database schema?
A collection of tables that defines how the data in a relational database should be organized
What is a table in terms of relational databases?
AKA relations. A table is a list of rows each having the same set of attributes.
What is a row?
A record within the the data table
What is SQL and how is it different from languages like JavaScript?
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 do you retrieve specific columns from a database table?
By using the select statement
How do you retrieve specific columns from a database table?
By using the where clause
What are the benefits of formatting your SQL?
consistent style and readability
What are four comparison operators that can be used in a where clause?
=, !=, >, and <
How do you limit the number of rows returned in a result set?
by using the limit keyword
How do you retrieve all columns from a database table?
by selecting with an * asterisk
How do you control the sort order of a result set?
by using the order by clause
How do you add a row to a SQL table?
by using the insert statement
What is a tuple?
a list of values in SQL
How do you add multiple rows to a SQL table at once?
by specifying more than one tuple of values, separated by commas
How do you get back the row being inserted into a table without a separate select statement?
by using the returning clause with an * asterisk
How do you update rows in a database table?
By using the update statement
Why is it important to include a where clause in your update statements?
If you don’t use a where clause, every row in the table will be updated
How do you delete rows from a database table?
By using the delete statement
How do you accidentally delete all rows from a table?
By not including a where clause
What is a foreign key?
A column in a table that links the table to another table using a mutual identifying value
How do you join two SQL tables?
By using the join clause and identifying a mutual foreign key
How do you temporarily rename columns or tables in a SQL statement?
us the as keyword followed by the desired rename in double quotes
What are some examples of aggregate functions?
avg(), max(), min(), sum(), every()
What is the purpose of a group by clause?
to separate rows into groups to perform aggregate functions on only those groups of rows
What are the three states a Promise can be in?
- pending: initial state, neither fulfilled nor rejected.
- fulfilled: meaning that the operation was completed successfully.
- rejected: meaning that the operation failed.
How do you handle the fulfillment of a Promise?
By using Promise.then
How do you handle the rejection of a Promise?
By using Promise.catch
What is Array.prototype.filter useful for?
- 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
What is Array.prototype.map useful for?
Quickly apply transformations to each element within an array and returning an array with the new elements
What is Array.prototype.reduce useful for?
For reducing an array down to one element after performing operations on each element relative to its following element
What is “syntactic sugar”?
syntax within a programming language that is designed to make things easier to read or to express
What is the typeof an ES6 class?
Function
Describe ES6 class syntax.
class Something { constructor(a,b,c) { this.a = a; this.b = b; this.c = c; } prototypeMethod() { blah blah blah code } }
What is “refactoring”?
the process of restructuring existing computer code—changing the factoring—without changing its external behavior
What is Webpack?
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.
How do you add a devDependency to a package?
npm install –save-dev
What is an NPM script?
a way to bundle common shell commands for a project
How do you execute Webpack with npm run?
by adding a script command that will run it with the right keyword ex: “build”: “webpack”
How are ES Modules different from CommonJS modules?
- 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
What kind of modules can Webpack support?
- ECMAScript modules
- CommonJS modules
- AMD modules
- Assets
- WebAssembly modules
What is React?
A component-based JavaScript library for building user interfaces
What is a React element?
React elements are plain objects where the React DOM takes care of updating the DOM to match the React elements
How do you mount a React element to the DOM?
ReactDOM.render()
What is Babel?
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.
What is a Plug-in?
a software component that adds a specific feature to an existing computer program
What is a Webpack loader?
transformations that are applied to the source code of a module
How can you make Babel and Webpack work together?
By installing babel-loader
What is JSX?
a syntax extension to JavaScript that uses inline markup that looks like HTML and gets transformed to JavaScript
Why must the React object be imported when authoring JSX in a module?
JSX is just syntactic sugar so when it gets compiled to plain JS the React methods are being used
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
install the babel react JSX plugin and webpack
What is a React component?
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.
How do you define a function component in React?
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>; }
How do you mount a component to the DOM?
ReactDom.render()
What are props in React?
arguments passed into React components
How do you pass props to a component?
By passing the values as attributes when calling the React component
How do you write JavaScript expressions in JSX?
By wrapping the expressions within curly braces
How do you create “class” component in React?
extending the class to React.Component
How do you access props in a class component?
By using this.props
What is the purpose of state in React?
For containing data or information about the component. A component’s state can change over time; whenever it changes, the component re-renders.
How to you pass an event handler to a React element?
by passing it inside the JSX element
What Array method is commonly used to create a list of React elements?
The map method
What is the best value to use as a “key” prop when rendering lists?
the id of the item
What are controlled components?
An input form element whose value is controlled by React
What two props must you pass to an input for it to be “controlled”?
onChange and onSubmit
What does express.static() return?
A middleware for serving static files
What is the local __dirname variable in a Node.js module?
The directory name of the current module
What does the join() method of Node’s path module do?
It joins all provided path segments together with a slash (/) separator in between and returns the new conjoined path
What does fetch() return?
A Promise that resolves to a Response object
What is the default request method used by fetch()?
GET
How do you specify the request method (GET, POST, etc.) when calling fetch?
By including an object with the method property as the second argument when calling fetch
When does React call a component’s componentDidMount method?
immediately after a component is mounted (inserted into the tree)
Name three React.Component lifecycle methods.
componentDidMount()
componentDidUpdate()
componentWillUnmount()
How do you pass data to a child component?
By pass it through props