Skip to content

Database

Kevin Niland edited this page Mar 1, 2019 · 3 revisions

For this project, a number of different databases were considered, such as MongoDB, Firebase, MySQL, and Amazon S3. In the end, we ended up using two main ones: Firebase and MongoDB. There are several reasons why we chose to use these two databases, which are listed below.

Both databases (Firebase and MongoDB) have their own advantages and disadvantages:

Firebase

Advantages

  • JSON (Javascript Object Notation) storage - This means there is no barrier between the data and the objects.
  • Real-time data updates - Capable of handling real-time data updates between devices if the app does run off a centralized database and is updated by several users.
  • Cloud Computing - Data is stored on the cloud so the data is readily available everywhere.
  • Hosting - Google hosts all of the so there is no need to worry about hardware if storing large amounts of data.
  • Storage size - Firebase has a massive storage size potential. With the free bundle plan offered by Firebase, named Spark, there is the option to have 100 simultaneous connections, 1 GB in storage, and 10 GB in downloads with the Real Time Database Service and the option for 5 GB in storage, 30 GB in downloads, and 50,000 uploads/downloads with the File Storage Service.

Disadvantages

  • Overkill - Unless your app runs off one centralized database updated by a vast quantity of users, using Firebase can be a major overkill.
  • Migration - As mentioned above, Firebase uses a JSON format for its storage. This means you won't easily be able to migrate data to databases that use SQL.
  • Inconsistencies - Firebase supports offline operations. Main issue is if the client goes offline and then online, and you have concurrency on some input data, you might have inconsistencies.
  • Pricing - While Firebase is server-less, it doesn't mean it is cost-less. Firebase paid tiers come with a usage quota, plus overage fees if you exceed the plan limit.

MongoDB

Advantages

  • Flexible - MongoDB is a schema-less database. That means we can have any type of data in a seperate document. This allows us to store data of different types.
  • Sharding - Allows one to store large pieces of data by distributing to several servers connected to the application. If server cannot handle such big data, then there will be no failure condition. This is called "auto-sharding".
  • High speed - MongoDB is a document-orientated database. It is easy to access documents by indexing. Hence, it provide a fast query response -- 100 times faster than a relational database.
  • Easy environment setup - Easier to setup than a RDBMS. Also provides Javascript client for queries.

Disadvantages

  • High memory usage - MongoDB stores key names for each value pairs. Due to no functionality of joins, there is data redundancy. This results in increasing, unnecessary usage of memory.
  • Limited data size - You can have document size, not more than 16MB.
  • Limited nesting - You cannot not perform nesting of documents for more than 100 levels.
  • Joins not supported - MongoDB doesn’t support joins like a relational database. Yet one can use joins functionality by adding by coding it manually. But it may slow execution and affect performance.

Conclusion

We decided to use Firebase for the file storage aspect of our project due to the fact that it provides scalable, fast-access to storage. However, from further research we found that using a NodeJS server with Firebase storage was recently depreciated and focus was put on using Google Cloud instead, so we decided to go down that route.

We decided to use MongoDB for the user aspect of our project due to the fact that we are only storing simple information about each user, such as their name, username, email, etc. Due to this, we can store all this in a JSON format in a document. And since MongoDB is a document-orientated database, it is easy to access documents by indexing.

Clone this wiki locally