Swiggy Interview Questions
Practice with real Swiggy interview questions
01
A Software Engineer was asked
Asked in 2024
Q. Compare NoSQL and SQL databases in the context of a Swiggy-like application. What factors would influence your choice between the two?
Ans. When building a Swiggy-like application, the choice between NoSQL and SQL databases is crucial, as it impacts data modeling, scalability, and performance.
SQL Databases:
- Structure: SQL databases are relational and use structured query language (SQL) for defining and manipulating data. They store data in tables with predefined schemas.
- ACID Compliance: They provide strong consistency and support ACID (Atomicity, Consistency, Isolation, Durability) properties.
- Use Cases: Ideal for applications requiring complex queries and transactions, such as managing user accounts and orders.
NoSQL Databases:
- Structure: NoSQL databases are non-relational and can store unstructured or semi-structured data. They come in various types like document stores, key-value pairs, column-family stores, and graph databases.
- Scalability: They are designed for horizontal scalability, making them suitable for handling large volumes of data and high-velocity applications.
- Use Cases: Suitable for applications with high write loads and variable data structures, such as user-generated content and product catalogs.
Factors Influencing the Choice:
1. Data Structure: If the application requires complex relationships and transactions, a SQL database like PostgreSQL could be more suitable. For semi-structured data (like user reviews), a NoSQL database like MongoDB might be more appropriate.
2. Scalability Needs: For applications expecting rapid growth, a NoSQL database can provide better scalability.
3. Development Speed: NoSQL databases often allow for faster iterations and schema changes, which can be an advantage in agile development environments.
4. Consistency Requirements: If strong consistency is paramount (e.g., managing transaction records), SQL databases are favored.
Example of SQL Table Creation:
Example of NoSQL Document in MongoDB:
In summary, the choice between NoSQL and SQL databases should be based on the specific requirements of the application, including data structure, scalability, and the need for consistency.
Software EngineerCore Concept
02
A Software Engineer was asked
Asked in 2024
Q. Can you explain the four pillars of Object-Oriented Programming (OOP) and provide examples of each using Python?
Ans. The four pillars of Object-Oriented Programming (OOP) are Encapsulation, Abstraction, Inheritance, and Polymorphism. Below are detailed explanations and code examples for each pillar:
1. Encapsulation: This is the bundling of data (attributes) and methods (functions) that operate on the data into a single unit or class. Encapsulation restricts direct access to some of the object's components.
2. Abstraction: Abstraction is the concept of hiding the complex implementation details and showing only the essential features of the object.
3. Inheritance: Inheritance allows a class to inherit properties and methods from another class. This promotes code reusability.
4. Polymorphism: Polymorphism allows methods to do different things based on the object it is acting upon, even if they share the same name.
These examples illustrate the core principles of OOP, showcasing how they can be applied in Python.
Software EngineerCore Concept
