You're in an interview, and the interviewer asks,
here's how you can answer:
Sample Answer:
▶️ Tap on the text to Copy.
How many types of API functions are available in Node.js? Explain them.
here's how you can answer:
Sample Answer:
In Node.js, there are mainly two types of API functions: blocking (synchronous) and non-blocking (asynchronous).
Blocking functions execute code one line at a time, meaning the next line won’t run until the current task is finished. For example, when you use fs.readFileSync() to read a file, it waits until the file is completely read before moving on to the next line of code. This approach can slow down the application if the task takes a long time because it blocks everything else from running.
Non-blocking functions, on the other hand, let other code run while the task is happening in the background. For instance, fs.readFile() reads a file asynchronously and immediately moves on to the next line without waiting. This makes non-blocking functions much faster and more efficient, especially for tasks like reading files, making network requests, or interacting with a database.
Node.js relies heavily on non-blocking functions because they help the application handle many tasks at once without getting stuck, making it more responsive and scalable. This approach is great for high-performance applications like web servers, where you need to handle multiple requests at the same time without delays.
So, to sum it up: blocking functions execute tasks one by one, stopping other code from running, while non-blocking functions run tasks in the background, keeping everything else running smoothly.▶️ Tap on the text to Copy.
❤1
Entry-level Data Analysis Interview Preparation Questions with Answers
❤3
What are SQL functions?
SQL functions are predefined operations that can be invoked with specific arguments to perform computations, manipulate data, or return specific results.
These functions can be categorized into several types based on their purpose:
1. Scalar Functions: These functions operate on a single value and return a single value. eg: LEN(), CAST() etc.
2. Aggregate Functions: These functions operate on a set of values and return a single value summarizing that set. eg: SUM(), AVG() etc.
3. Analytic Functions (Window Functions): These functions perform calculations across a set of rows related to the current row. eg: ROW_NUMBER() etc.
4. Table-Valued Functions: Unlike scalar functions, table-valued functions return a table as a result. They can accept parameters and perform complex processing to generate the output table.
AGGREGATE FUNCTIONS:
An aggregate function is a function that performs a calculation on a set of values, and returns a single value. We often use aggregate functions when you have a lot of data and you want to summarize it in some way, like finding totals, averages, or extremes.
For example, imagine you have a bunch of numbers and you want to find the total, average, or maximum number. Aggregate functions help you do that.
We can also use these functions with a GROUP BY clause, which is like organizing your data into groups based on certain criteria. So, you can get summaries for each group separately.
Some examples for aggregate functions are given below:
1. MIN() - returns the smallest value within the selected column.
2. MAX() - returns the largest value within the selected column.
3. COUNT() - returns the number of rows in a set.
4. SUM() - returns the total sum of a numerical column.
5. AVG() - returns the average value of a numerical column.
📌Other than COUNT(), aggregate functions ignore null values.
LIKE OPERATOR:
"LIKE" is an operator that helps you search for patterns within text data. Like finding all the words that start with a certain letter or contain a specific sequence of characters.
What are wildcards?
Wildcards are symbols used in conjunction with the "LIKE" operator in SQL to represent one or more characters in a search pattern. They act as placeholders for unknown or variable characters, allowing you to search for patterns rather than exact matches.
Types:
1. % (Percent Sign): This wildcard represents zero, one, or multiple characters. It can be used to match any sequence of characters.
2. _(Underscore): This wildcard represents a single character. It matches any single character in that position of the string.
SQL functions are predefined operations that can be invoked with specific arguments to perform computations, manipulate data, or return specific results.
These functions can be categorized into several types based on their purpose:
1. Scalar Functions: These functions operate on a single value and return a single value. eg: LEN(), CAST() etc.
2. Aggregate Functions: These functions operate on a set of values and return a single value summarizing that set. eg: SUM(), AVG() etc.
3. Analytic Functions (Window Functions): These functions perform calculations across a set of rows related to the current row. eg: ROW_NUMBER() etc.
4. Table-Valued Functions: Unlike scalar functions, table-valued functions return a table as a result. They can accept parameters and perform complex processing to generate the output table.
AGGREGATE FUNCTIONS:
An aggregate function is a function that performs a calculation on a set of values, and returns a single value. We often use aggregate functions when you have a lot of data and you want to summarize it in some way, like finding totals, averages, or extremes.
For example, imagine you have a bunch of numbers and you want to find the total, average, or maximum number. Aggregate functions help you do that.
We can also use these functions with a GROUP BY clause, which is like organizing your data into groups based on certain criteria. So, you can get summaries for each group separately.
Some examples for aggregate functions are given below:
1. MIN() - returns the smallest value within the selected column.
2. MAX() - returns the largest value within the selected column.
3. COUNT() - returns the number of rows in a set.
4. SUM() - returns the total sum of a numerical column.
5. AVG() - returns the average value of a numerical column.
📌Other than COUNT(), aggregate functions ignore null values.
LIKE OPERATOR:
"LIKE" is an operator that helps you search for patterns within text data. Like finding all the words that start with a certain letter or contain a specific sequence of characters.
What are wildcards?
Wildcards are symbols used in conjunction with the "LIKE" operator in SQL to represent one or more characters in a search pattern. They act as placeholders for unknown or variable characters, allowing you to search for patterns rather than exact matches.
Types:
1. % (Percent Sign): This wildcard represents zero, one, or multiple characters. It can be used to match any sequence of characters.
2. _(Underscore): This wildcard represents a single character. It matches any single character in that position of the string.
❤1👍1
Understanding OAuth
OAuth is an open standard that allows users to grant limited access to their data on one site to other sites or applications without exposing their passwords.
The OAuth ecosystem
OAuth connects three main players:
- The User who wants to grant access to their data without sharing login credentials
- The Server that hosts the user's data and provides access tokens
- The Identity Provider (IdP) that authenticates the user's identity and issues tokens
How OAuth works
When a user tries to access their data through a third-party app, they are redirected to log in through the IdP. The IdP sends an access token to the app, which presents it to the server. Recognizing the valid token, the server grants access.
The OAuth flows
OAuth 2.0 defines 4 flows for obtaining authorization tokens:
- Authorization Code Flow - for server-side applications
- Client Credentials Flow - when the app is the resource owner
- Implicit Code Flow - not secure and no longer recommended
- Resource Owner Flow
OAuth is an open standard that allows users to grant limited access to their data on one site to other sites or applications without exposing their passwords.
The OAuth ecosystem
OAuth connects three main players:
- The User who wants to grant access to their data without sharing login credentials
- The Server that hosts the user's data and provides access tokens
- The Identity Provider (IdP) that authenticates the user's identity and issues tokens
How OAuth works
When a user tries to access their data through a third-party app, they are redirected to log in through the IdP. The IdP sends an access token to the app, which presents it to the server. Recognizing the valid token, the server grants access.
The OAuth flows
OAuth 2.0 defines 4 flows for obtaining authorization tokens:
- Authorization Code Flow - for server-side applications
- Client Credentials Flow - when the app is the resource owner
- Implicit Code Flow - not secure and no longer recommended
- Resource Owner Flow
❤1
System Design Blueprint
This template helps to tackle various system design problems in interviews.
Hope this checklist is useful to guide your discussions during the interview process.
This briefly touches on the following discussion points:
- Load Balancing
- API Gateway
- Communication Protocols
- Content Delivery Network (CDN)
- Database
- Cache
- Message Queue
- Unique ID Generation
- Scalability
- Availability
- Performance
- Security
- Fault Tolerance and Resilience
- And more
This template helps to tackle various system design problems in interviews.
Hope this checklist is useful to guide your discussions during the interview process.
This briefly touches on the following discussion points:
- Load Balancing
- API Gateway
- Communication Protocols
- Content Delivery Network (CDN)
- Database
- Cache
- Message Queue
- Unique ID Generation
- Scalability
- Availability
- Performance
- Security
- Fault Tolerance and Resilience
- And more
❤2
Coding interview preparation
SQL question: What will this query return?
Hey everyone, quick follow-up to today’s SQL quiz!👇
The query was:
Our active members picked B) 1, C) 0 or D) Error… but let’s break it down real quick! ⚡
➡️ COUNT(*) in the SELECT counts ALL rows in the table → with 10 rows it returns 10
➡️ The HAVING clause filters after aggregation
➡️ HAVING COUNT(*) > 0 simply checks if the total count is greater than 0 (which it always is unless the table is empty)
🟢 So the query returns exactly one row with the value 10.
The question was a valid (just a bit tricky/wordy) way to write
Correct answer: A) 10 ✅
Unfortunately no one got it right😅
Better luck next time folks, you’re all still SQL legends in my book! 💙
The query was:
SELECT COUNT(*) FROM employees HAVING COUNT(*) > 0;
Our active members picked B) 1, C) 0 or D) Error… but let’s break it down real quick! ⚡
➡️ COUNT(*) in the SELECT counts ALL rows in the table → with 10 rows it returns 10
➡️ The HAVING clause filters after aggregation
➡️ HAVING COUNT(*) > 0 simply checks if the total count is greater than 0 (which it always is unless the table is empty)
🟢 So the query returns exactly one row with the value 10.
The question was a valid (just a bit tricky/wordy) way to write
give me the total row count, but only if there’s at least one row
Correct answer: A) 10 ✅
Unfortunately no one got it right😅
Better luck next time folks, you’re all still SQL legends in my book! 💙
❤1