Introduction
The database design process for NoSQL databases is different from one for relational (SQL) databases.
As we learned NoSQL database does not require the use of a predefined structure, except for creating a list of databases and the list of collections. Some of the NoSQL databases (like MongoDB) allow us to define what the structure should be for certain rules that will define what should be the structure of the acceptable documents for each collection.
As you may recall, when you need to store multiple data points in a relational database, you use multiple records (rows), where each record and then values to describe properties of that record will be placed in the columns. Unlike relational databases, NoSQL databases allow two ways of storing multiple values (lists):
By creating multiple documents (one per record);
By creating lists within a single document.
The choice between one or the other is based on the potential size of the list, size of the records, and the most common operations the database will need to process. The rule of thumb will be if the list changes regularly and each item in the list is complex (an object itself), not very well connected to the other items, or the list is very long, then use one document per record approach. Note that the size of the document may also be limited (e.g. 15MB for a MongoDB document).
If the list is small, each record is small records, and will unlikely change often, then you can make the entire list to be a single document.
You may read more about the best practices of MongoDB design (
https://www.mongodb.com/blog/post/6-rules-of-thumb-for-mongodb-schema-design
).
Business Case
A car-sharing company decided to use a MongoDB NoSQL database to store information about their primary operations, which include recording of all rides, real-time car locations, and users. A ride is defined as a combination of pick-up location, and drop-off locations (if the car has been returned), with the associated timestamps of those events.D
Directions
In this assignment, you will propose a database structure for the given business case. It should include the list of collections, and one sample document (in JSON format) for each collection to demonstrate the document structure.