Senior Flashcards
Internet vs World Wide Web
internet is the network of connected computers
(servers or wifi)
world wide web are websites or pages
(link between html documents)
get those html documents with http requests
urls and http requests
NPM-INTRO
What is NPM?
npm is the world’s largest software registry. Open source developers from every continent use npm to share and borrow packages, and many organizations use npm to manage private development as well.
npm consists of three distinct components:
the website
the Command Line Interface (CLI)
the registry
NPM-INTRO
What is a package?
A package is a file or directory that is described by a package. json file. A package must contain a package. json file in order to be published to the npm registry.
package is a collection of code that is pre-written
directory with files
package is a directory with one of more files in it, plus a package.json
NPM-INTRO
How can you create a package.json with npm?
[ npm ] command
To create a default package.json using information extracted from the current directory, use the npm init command with the –yes or -y flag.
NPM-INTRO
What is a dependency and how to you add one to a package?
Packages required by your application in production
Third party code that application is required to function
npm install
NPM-INTRO
What happens when you add a dependency to a package with npm?
EXPRESS-INTRO
How do you add express to your package dependencies?
NPM INSTALL EXPRESS
EXPRESS-INTRO
What Express application method starts the server and binds it to a network PORT?
The app. listen() function is used to bind and listen the connections on the specified host and port. This method is identical to Node’s http. Server.
Network Interface is a piece of hardware on a computer that allows network connectivity (internet)
each network interface is given its own IP address on your network
examples: wifi card / adapter, LAN card or adapter
LAN: Local Area Network (ethernet cable)
your phone and laptop have wifi cards
your laptop may have LAN
your desktop probably has LAN (maybe both)
every network interface provides 2^16 “ports”
the default (aka “well-known”) HTTP port is actually 80
the default (aka “well-known”) HTTPS port is actually 443
any port number below 1024 requires “admin” privileges to use
what is the difference between a library and a framework?
a library is code that someone else wrote (or a separate part of your codebase)
a library should be reusable (flexible)
a framework is a specific kind of library
a framework is different from a library when it has “inversion of control”
who calls who? (the hollywood principle) “don’t call us; we’ll call you”
a framework calls YOUR code
a library is called by your code
a framework describes WHEN to call your functions (you don’t call them)
- event system of the DOM is a framework (event listener)
- anything that uses events sis definitely a framework
EXPRESS-HELLO-WORLD
How do you mount a middleware with an Express application?
use the ‘use’ method on an express object
i.e. app.use( )
EXPRESS-HELLO-WORLD
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object and response obeject
The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on.
Req: a data model of the HTTP request message (from the Client!)
Res: a data model of the HTTP response message (to the Client!)
The res object represents the HTTP response that an Express app sends when it gets an HTTP request.
EXPRESS-GET-JSON
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
EXPRESS-POST-JSON
What does the express.json() middleware do and when would you need it?
parses incoming json body and need it when parsing incoming json bodies
POSTGRE-DATABASE
What is a database schema?
A database schema is considered the “blueprint” of a database which describes how the data may relate to other tables or other data models.
The database schema is the structure of a database described in a formal language supported by the database management system. The term “schema” refers to the organization of data as a blueprint of how the database is constructed.
A database schema defines how data is organized within a relational database; this is inclusive of logical constraints such as, table names, fields, data types, and the relationships between these entities
defines the structure of a database
POSTGRE-DATABASE
What is a table?
list of rows
attributes
data types
POSTGRE-DATABASE
What is a row?
each row is a single record of data
each row is an instance for all attributes
the table defines defines what attributes or columns each row should have
but row is a record or once instance of all of that.
SQLstands for Structured Query Language and it’s different from JavaScript because it’s a declarative langauge. SQL is like HTML and CSS where you describe the results and the programs renders the results.
imerperative (JavaScript) you tell it steps it needs to take
SELECT “thisColumn”, “thatColumn”
FROM thisTable;
SELECT “thisColumn”, “thatColumn”
FROM thisTable
WHERE “thisColumn” > 1;
looks cleaner and easier to read
use the limit clause
use * / asterisks
SQL-INSERT
How do you add a row to a SQL table?
insert into “table” (“col1”, “col2”)
values (‘hello’, ‘world’);
SQL-INSERT
What is a tuple?
tuple is a data structure like an array
a list of values
two tuples with same structure and each position refers to
SQL-JOIN
What is a foreign key?
a foreign key is a column used in another table to link them
constraint that one column has to match the other column
SQL-JOIN
How do you join two SQL tables?
use the join clause
select *
from “thisTable”
join “thisOtherTable” using (“thisColumn”);
SQL-JOIN
How do you temporarily rename columns or tables in a SQL statement?
use alias, can use them for more than just select statements
select “firstName” as “first”
from “thisTable” as “table”
join “otherTable” as “other”;
What do aggregate functions do?
Return a single value
Return a bunch of values into a single value