saukumar95 / expensify-api

Backend api for Expensify App
MIT License
0 stars 0 forks source link

Identify the database to use in this app - MongoDB or anyother DB #4

Open saukumar95 opened 11 months ago

Gaurav2k50 commented 11 months ago

Sir, today I read about rdbms in rdbms - I have read Key Components: Tables, Rows, Columns, Keys. in it I read types of rdbms - 1) MySQL ,2) Oracle Database, 3) Microsoft SQL Server, 4) PostgreSQL, 5) SQLite. How rdbms work - Data Modeling, Data Entry, Data Retrieval, Data Maintenance, Integrity and Security,

Explanation:- An RDBMS is like a digital filing cabinet where information is organized into tables. Each table contains rows (like individual files) and columns (like different types of information in each file). Keys are used to connect these tables, ensuring data is linked accurately. It allows you to efficiently store, retrieve, and manage data in a structured manner. Popular examples include MySQL, Oracle, and SQL Server.

Gaurav2k50 commented 11 months ago

Understanding MySQL:

MySQL, a powerful relational database management system, stands out for its efficiency and versatility in handling data. Its robust architecture and seamless integration make it a preferred choice for various applications. Why MySQL is a Preferred Choice: MySQL is widely embraced for several compelling reasons:

  1. Performance:
    • MySQL excels in delivering high performance, ensuring swift data retrieval and processing.
  2. Scalability:
    • The scalability of MySQL allows it to grow seamlessly with the expanding needs of your data-driven applications.
  3. Open Source:
    • As an open-source database, MySQL offers the advantage of accessibility, allowing users to modify and customize according to their requirements.
  4. Community Support:
    • The MySQL community is vibrant and active, providing a valuable resource for assistance, troubleshooting, and continuous improvement.

MySQL vs. Other Databases: Let's compare MySQL with other databases to better understand its unique attributes:

  1. Reliability:
    • MySQL is renowned for its reliability, ensuring data integrity and consistent performance
  2. Ease of Use:
    • The user-friendly interface of MySQL simplifies database management, making it accessible to both novices and experienced users.
  3. Cost-Effective:
    • MySQL's open-source nature makes it a cost-effective solution, eliminating the need for hefty licensing fees.

Advantages and Disadvantages: Advantages: -Scalability: MySQL grows seamlessly with your data requirements. -Performance: Ensures swift data retrieval and processing. -Community Support: Active community for assistance and improvement.

Disadvantages:

In conclusion, MySQL stands as a reliable, scalable, and cost-effective database solution, catering to a wide range of applications. While it has its advantages, understanding its limitations is crucial for making informed decisions in database management.

Gaurav2k50 commented 11 months ago

PostgreSQL: Overview

PostgreSQL is an open-source relational database management system (RDBMS) known for its advanced features, extensibility, and standards compliance. Here are some key points about PostgreSQL:

Advantages:

  1. Advanced Features: PostgreSQL supports advanced data types, indexing methods, and features such as full-text search, GIS, and JSONB (binary JSON).

  2. Extensibility: It allows users to define their own data types, operators, and functions, making it highly extensible for specific application needs.

  3. Standards Compliance: PostgreSQL adheres to SQL standards and supports ACID (Atomicity, Consistency, Isolation, Durability) properties, ensuring data integrity and reliability.

  4. Scalability: It is designed to handle large amounts of data and concurrent transactions, making it suitable for both small and large-scale applications.

  5. Concurrency Control: PostgreSQL employs Multi-Version Concurrency Control (MVCC), allowing multiple transactions to occur concurrently without interfering with each other.

  6. Community and Support: PostgreSQL has a strong and active open-source community, providing support, documentation, and a wide range of extensions.

Disadvantages:

  1. Learning Curve: Compared to some NoSQL databases, PostgreSQL may have a steeper learning curve, especially for those new to relational databases.

  2. Performance: While PostgreSQL performs well in many scenarios, the optimal choice depends on your specific use case. Some NoSQL databases might outperform PostgreSQL in certain read or write-heavy scenarios.

  3. Resource Consumption: In some cases, PostgreSQL may consume more system resources compared to lighter-weight databases. Proper tuning is essential for optimal performance.

How PostgreSQL Works:

Use in Expensify App:

PostgreSQL is a solid choice for applications like Expensify, where you have structured data and transactions that require ACID compliance. Here are considerations:

In conclusion, PostgreSQL is a robust and feature-rich RDBMS that can be a suitable choice for many applications, including those dealing with financial data like an expense management app.

Gaurav2k50 commented 11 months ago

PostgreSQL: Overview SQLite is a self-contained, serverless, and zero-configuration relational database engine. Here are some key characteristics, advantages, and disadvantages of SQLite, and considerations for using it in your Expensify app:

Characteristics of SQLite:

  1. Serverless:

    • SQLite is serverless, meaning it doesn't require a separate server process to operate. The entire database is a single ordinary file on disk.
  2. Self-contained:

    • The SQLite library is self-contained and doesn't have external dependencies, making it easy to deploy and manage.
  3. Zero-Configuration:

    • There is minimal setup required. You don't need to configure a separate server or manage user accounts and permissions.
  4. Single User Access:

    • SQLite is suitable for applications with relatively low concurrency or single-user access scenarios.

Advantages of SQLite:

  1. Portability:

    • The database is a single file, making it highly portable. You can easily transfer the entire database by copying the file.
  2. Ease of Use:

    • SQLite is easy to set up and use, especially for smaller projects or applications where simplicity is a priority.
  3. Low Resource Usage:

    • It has a small memory footprint, making it suitable for embedded systems and mobile devices with limited resources.
  4. Transactional Support:

    • SQLite supports ACID properties (Atomicity, Consistency, Isolation, Durability) and transactions, ensuring data integrity.
  5. Embeddable:

    • As it's a self-contained library, you can embed SQLite directly into your application without the need for a separate database server.

    Disadvantages of SQLite:

  6. Concurrency Limitations:

    • SQLite might not be the best choice for high-concurrency scenarios or applications with many write operations simultaneously.
  7. Scaling Challenges:

    • While SQLite is suitable for small to medium-sized applications, it may face scaling challenges in larger applications or systems with high traffic.
  8. Limited Server-Side Functionality:

    • As it's serverless, SQLite lacks some features commonly found in client-server relational database management systems.

Use Cases for SQLite in Expensify App:

  1. Mobile Apps:

    • SQLite is commonly used in mobile app development, especially for Android and iOS applications, due to its lightweight nature.
  2. Prototyping and Small Projects:

    • It's well-suited for prototyping or small projects where simplicity and ease of use are essential.
  3. Single-User Applications:

    • If your Expensify app is primarily used by individual users or small teams, and you don't anticipate heavy concurrent access, SQLite could be a suitable choice.
  4. Situations Requiring Portability:

    • If you need a portable solution that can be easily transferred or shared, SQLite's single-file approach is advantageous.
  5. Offline Data Storage:

    • SQLite is useful for applications that need to store data locally and support offline functionality.

In summary, SQLite is a good choice for scenarios where simplicity, portability, and ease of use are critical. If our Expensify app is relatively small, doesn't require high concurrency, and you value the benefits of a serverless, embedded database, SQLite could be a suitable option. However, if you anticipate significant scalability needs or concurrent access, you may want to consider other databases with client-server architecture.

Gaurav2k50 commented 11 months ago

MongoDB is a popular, open-source NoSQL database that is designed to handle large amounts of data and provide high performance and scalability. Here's an overview of how MongoDB works and its advantages and disadvantages:

How MongoDB Works:

1.Document-Oriented: MongoDB stores data in a flexible, JSON-like format called BSON (Binary JSON). BSON documents can contain nested arrays and subdocuments, making it easy to represent complex data structures.

  1. Collections and Documents: Data is organized into collections, which are analogous to tables in relational databases. Each collection contains documents, which are individual records.

  2. Schema-less: MongoDB is schema-less, meaning that documents in a collection can have different fields and data types. This flexibility is useful for handling evolving data structures.

  3. Indexes: MongoDB supports indexing, which can improve the performance of queries by allowing the database to quickly locate and retrieve specific documents.

  4. Query Language:MongoDB uses a rich query language that supports a wide range of queries, including geospatial queries.

Advantages of MongoDB:

  1. Schema Flexibility: As mentioned, MongoDB's flexible schema allows you to easily evolve your data model as your application requirements change.

  2. Scalability: MongoDB is designed to scale horizontally, meaning you can add more servers to distribute the load and handle increasing amounts of data.

  3. Performance: MongoDB can handle large amounts of data and provide fast read and write operations.

  4. JSON-Like Documents: The use of BSON documents makes it easy to work with data in a format similar to JSON, which is widely used in web development.

  5. Rich Query Language: MongoDB supports a powerful and expressive query language, making it easy to retrieve and manipulate data.

Disadvantages of MongoDB:

  1. No ACID Transactions Across Documents: MongoDB supports ACID transactions within a single document, but transactions that involve multiple documents are not fully ACID-compliant.

  2. Memory Usage: MongoDB may use more memory compared to some other databases.

  3. Learning Curve: For those accustomed to relational databases, the transition to MongoDB's document-oriented model may have a learning curve.

  4. Not a One-Size-Fits-All Solution: While MongoDB is suitable for many use cases, it may not be the best choice for every application. Consider your specific requirements before choosing a database.

Using MongoDB for Expensify App:

Yes, you can use MongoDB for your Expensify app. MongoDB's flexibility and scalability make it well-suited for applications with varying data structures and growing datasets. Here are some benefits for your Expensify app:

  1. Flexible Data Model: Expenses may have different attributes, and MongoDB's schema flexibility allows you to adapt to changes in your expense data structure over time.

  2. Scalability: As your user base and the volume of expense data grow, MongoDB's horizontal scaling capabilities can help ensure that your app maintains performance.

  3. Rich Query Support: MongoDB's query language enables you to efficiently retrieve and analyze expense data based on various criteria.

  4. JSON-Like Documents: Storing expenses as BSON documents allows you to work with data in a format that aligns well with the JSON data often used in web development.

So I feel that Mongo will remain dominant compared to others and we should use mongo db in our project.