Senior Side Week 2 & 3 Flashcards
What is a client?
A client is a computer program or device that requests services or resources from a server.
The client sends a request to the server, which processes the request and sends a response back to the client.
Example: A broswer
What is a server?
A server is a computer program or device that provides services or resources to clients.
The server is responsible for processing requests from clients and returning the requested information or service.
Examples: web servers, mail servers, file servers, database servers, and game servers.
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
What is on the first line of an HTTP request message?
HTTP Method, Request Target, HTTP Version
What is on the first line of an HTTP response message?
Protocol Version, Status Code, Status Text
What are HTTP headers?
HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:), then by its value
Is a body required for a valid HTTP message?
Depends on the specific requirements of the HTTP method being used and the specific circumstances of the request or response.
For some HTTP methods, such as GET and HEAD, a message body is not required, and any included message body would be ignored by the server. For other methods such as POST, PUT, and DELETE, a message body may be required to send or modify data associated with the request.
What is NPM?
NPM is the world’s largest software registry. Open source developers from every continent use npm to share and borrow packages.
The 3 components in the npm is:
the website
the command line interface (CLI)
the registry
What is a package?
A package is a file or directory that is described by a ‘package.json’. A package must contain a ‘package.json’ file in order to be published to the npm registry.
How can you create a package.json with npm?
npm init –yes
What is a dependency and how do you add one to a package?
In package.json file, there is an object called dependencies and it consists of all the packages that are used in the project with its version number. So, whenever you install any library that is required in your project that library you can find it in the dependencies object.
Basically means that the package depends on this.
Version:
The first number is the major version.
The second number is the minor version.
The third number is the bug fix version.
You can add on either through the command line or manually editing the ‘package.json’ file.
Command line: npm install <package-name></package-name>
What happens when you add a dependency to a package with npm?
It gets stored in the ‘package.json’ file. It creates a node.modules directory and adds a line in your package.json. It goes to the npm registry and adds it to the node.modules file.
What are some other popular package managers?
Yarn and PNPM
What is Express useful for?
Implementing the HTTP endpoints for web applications. Help manage routes.
How does Express fit into a full-stack web application?
It is on the server side and it does the communication for the backend and the frontend.
It manages the HTTP messages.
How do you add ‘express’ to your package dependencies?
Writing ‘npm install express’ in your command line
What Express application method starts the server and binds it to a network ‘port’?
The listen method(). A port is endpoint of communication in an operating system.
What is Express middleware?
It is a set of functions in the Express.js web application framework that are executed in between the processing of an incoming HTTP request and the generation of an HTTP response
What is Express middleware useful for?
It can be used to perform various tasks such as logging, authentication, parsing incoming data, and serving static files, among others.
It is in between with request coming in and response coming out.
How do you mount a middleware with an Express application?
app.use and pass in a function
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request, response, next
What is an API endpoint?
An API endpoint is a specific location or URL within an API (Application Programming Interface) that is used to access and interact with its functionality.
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What is the significance of an HTTP request’s method?
It let’s the server know what the client wants
What does the express.json() middleware do and when would you need it?
It parses incoming requests with JSON. It is needed when we need to parse JSON data.
Why do we use databases in Web development?
Databases are used to store data. It is accessible by many users thus providing a centralized location for application data.
What is PostgreSQL and what are some alternative relational databases?
PostgreSQl is an open-source relational database management system that is known for its reliability, scalability, and advanced features.
Alternatives:
MySQL
Oracle database
Microsoft SQL
SQLite
What are some advantages of learning a relational database?
1) Efficient Data Management
2) Data Integrity
3) We learn it so store data
Relational database is a database structure that recognize relations among stored items of information.
What is one way to see if PostgreSQL is running?
Write in the command line:
sudo service postgresql status
What is a database schema?
A schema is a collection of tables. A schema defines how the data in a relational database should be organized and structured.
What is a table?
A table is a list of rows each having the same set of attributes.
What is a row?
A row is a single record or a set of related data in a table.
It’s a single set of data or object or item that has similar columns.
What is an attribute and what other names are used to describe them?
Attributes are commonly known as columns.
Attributes are the individual data elements or properties of an entity that are stored in a database table. They describe the characteristics of the entity, and they are organized in columns in the table.
Attributes have defined data types.
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 powerful way of retrieving, creating, and manipulating dat in a relational database.
It is different from Javascript because JavaScript is an imperative programming languages. SQL is a declarative programming language. In declarative languages, the programmers describe the results they want and the programming environment comes up with its own plan for getting those results.
How do you retrieve specific columns from a database table?
By using the select statement.
How do you filter rows based on some specific criteria?
By using the syntax ‘order by’ followed by a column name. It comes after the from clause. Default setting is ascending order.
What are the benefits of formatting your SQL?
Readability
What are four comparison operators that can be used in a ‘where’ clause?
= equal
!= not equal
< less than
> greater than
How do you limit the number of rows returned in a result set?
By using the ‘limit’ clause. It always comes last. It is a literal integer number.
How do you retrieve all columns from a database table?
Using the * sign