Groww Interview Questions
Practice with real Groww interview questions
01
A Software Engineer was asked
Asked in 2024
Q. What are SQL subqueries and nested queries? Provide examples and explain their use cases.
Ans. SQL subqueries and nested queries are powerful tools for performing complex queries. A subquery is a query within another SQL query, while a nested query refers to a query placed inside another query's
FROM or WHERE clause.
Example of a Subquery:
Explanation:
- This query selects user names from the Users table where the UserID exists in the result set of the subquery, which retrieves UserIDs from the Orders table with an OrderAmount greater than 100.
Example of a Nested Query:
Explanation:
- This nested query retrieves user names along with the count of their corresponding orders. The subquery counts the number of orders for each user based on their UserID.
Use Cases:
- Subqueries are useful when you want to filter records based on the results of another query, such as finding users with orders above a certain amount.
- Nested Queries can be used when you need to calculate aggregates or perform calculations based on another query, like counting related records.
Edge Cases:
- Be cautious with performance; subqueries can be less efficient than JOINs for large datasets. Also, ensure that the subquery returns a compatible data type with the outer query for correct execution.Software EngineerCore Concept
02
A Backend Developer was asked
Asked in 2024
Q. What are the key differences between REST and GraphQL API design? Provide a scenario where one might be preferred over the other.
Ans. REST and GraphQL are both approaches to API design but have significant differences:
1. Data Fetching: In REST, the client often makes multiple requests to different endpoints to gather related data. In GraphQL, clients can request all necessary data in a single query.
2. Versioning: REST APIs often require versioning (e.g., /v1/users) when changes occur. GraphQL APIs evolve without versioning, as clients specify their data needs.
3. Response Structure: REST responses can be verbose, with fixed data structures. GraphQL allows clients to specify the exact shape of the response.
Scenario: If you are building a mobile application that needs to display user profiles with varying levels of detail depending on user preferences, GraphQL would be a better choice due to its flexibility in fetching exactly what the client needs in a single request. In contrast, if you are developing a simpler application where each endpoint serves a specific resource (like an e-commerce API), REST could be more straightforward to implement.
Backend DeveloperCore Concept
