Database Architecture

Database Structure

As we are using MongoDB, a NoSQL database, we do not have a fixed schema or rigid entity relationship between the tables. However, we did plan an initial database structure using a basic ER Diagram to follow as a guide during development.

Initial ER Diagram

Database Architecture Revised

Revised MongoDB ER Diagram

Database Architecture

Reasoning

We chose MongoDB as a learning experience and because we initially felt that the structure of the chat application would not require any complex relationships or queries. NoSQL databases like MongoDB offer an efficient way to write simple data to documents in a fast and efficient way without the overhead of a SQL interpreter.

We designed the structure of the database to try and have a limited number of tables and relationships, with all data in consistent groupings for fast read and write. We made extensive use of the Array and Object data types that MongoDB offers in order to maintain efficiency and easily map the data to variables in the code.

In practice however, we found that MongoDB had a number of shortcomings and limitations that slowed development. As there is not fixed schema to ensure the consistency of data and the relationships between those data points, all the rules for reading and writing must be managed within the backend code.

In hindsight, using an SQL-based database system that we were more familiar with would have reduced the number of issues we faced with data consistency and rules management. If the chat application was just one big public forum with limited rules, MongoDB would have been the perfect choice.

Scalability

We hosted our MongoDB database on Atlas, a cloud hosted database management platform that removes the need for managing the underlying server infrastructure and software, allowing us to focus on the development of the application.

MongoDB Atlas offers a number of tiers which run on either dedicated hardware or a shared virtualised instance, with a wide selection of processing power, memory and storage limits.

For this assignment we are using the free tier that is a shared M0 AWS virtual server with 512MB of storage which could be easily moved to a higher tier of server to cope for a much higher load.

MongoDB stores the database as a group of shared clusters and allows for scaling by automatically increasing the number of clusters to manage increased load, or reducing the number of clusters to save resources when requests are reduced. The clusters allow for parallel processing of data requests and can be configured to replicate all data for redundancy.