Question

In: Computer Science

The database design process for noSQL databases is different from one for relational (SQL) databases. As...

The database design process for noSQL databases is different from one for relational (SQL) databases.

As we learned noSQL database does not require to have a predefined structure, except of creating a list of databases and the list of collections. Some of the noSQL databases (like MongoDB) allow to define 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 another 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 or 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, it has with small records, and unlikely change often, then you can make it as a part of one document.

For example, if you have a database of the business transactions, and there could be millions of those transactions recorded per minute, create a new document for each of them with me more efficient choice. In contrary, when you store information about degrees that an employee earned, which will be updated rarely, all degrees can be combined into a list in one employee profile document.

MongoDB also allows to use relational database – like relations, by using a document id as a value in another document.

You may read more about best practices of MongoDB design (Links to an external site.).

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 defined as combination of pick-up location, drop-off locations (if the car has been returned), with the associated timestamps of the those events.

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.

Put the list of the collections with the comments on their role along with the sample documents in JSON format in a single .txt file and submit it.

Solutions

Expert Solution

The following three collections are proposed :-

(Please ignore the type of values of keys. I am stating them as empty strings for my own convinience. Actually, they ought to be treated with common knowledge. For example, PIN will be an integer and so on.)

1) User Collection - It has all the required information about all the users

{  
   "users":{
        "userId":"",
        "registered":"",
        "name":{
            "firstName":"",
            "middleName":"",
            "lastName":""
        },
        "contactNo":{
            "value":"",
            "verified":""
        },
        "emailId":{
            "value":"",
            "verified":""
        },
        "paymentMethods":[
            {
                "cards":{
                    "cardNo":"",
                    "cvv":"",
                    "type":""
                },
                "onlineWallets":[
                    {
                        "name":"",
                        "verified":""
                    }
                ]
            }
        ],
        "homeAddress":{
            "coordinates":"",
            "address-line1":"",
            "address-line2":"",
            "city":"",
            "state":"",
            "landmark":"",
            "country":"",
            "pin":""
        },
        "savedAddresses":[
            {
                "coordinates":"",
                "address-line1":"",
                "address-line2":"",
                "city":"",
                "state":"",
                "landmark":"",
                "country":"",
                "pin":""
            }
        ]
    }

}

2) Rides Collection - It has all the required information about all the rides happening.

{

    "rides":[
        {
            "userId":"",
            "pickupData":{
                "location":{
                    "coordinates":"",
                    "addressLine1":"",
                    "addressLine2":"",
                    "city":"",
                    "state":"",
                    "landmark":"",
                    "country":"",
                    "pin":""
                },
                "time":""
            },
            "dropoff":{
                "location":{
                    "coordinates":"",
                    "addressLine1":"",
                    "addressLine2":"",
                    "city":"",
                    "state":"",
                    "landmark":"",
                    "country":"",
                    "pin":""
                },
                "time":""
            },
            "paymentMethod":"",
            "vehicle":{}
        }
    ]

}

3) Real Time LocationCollection - It has all the required information about all the real time locations of the cars.

{

    "real-time-locations":[
        {
            "vehicleId":"",
            "locationTimestamp":"",
            "duration":"",
            "coordinates":"",
            "addressLine1":"",
            "addressLine2":"",
            "city":"",
            "state":"",
            "landmark":"",
            "country":"",
            "pin":""
        }
    ]

}

Other similar collections that could be made are vehicle information etc.


Related Solutions

Compare the Data Modeling difference between relational database and NoSQL MongoDB.
Compare the Data Modeling difference between relational database and NoSQL MongoDB.
Subject: Database Design System and Management We have been introduced to the concept of Relational databases,...
Subject: Database Design System and Management We have been introduced to the concept of Relational databases, SQL, Business rules, Centralized and Distributed database systems. Write 2/3 paragraph and discuss: Q: How important are Relational Debase Management System in business operations and productivity? What is your level of comfort with this technology? How important are Logical database design and what was your favorite topic.?   
One of the characteristics of good relational database design is normalized tables. Discuss two ways in...
One of the characteristics of good relational database design is normalized tables. Discuss two ways in which normalization helps minimize data redundancy and anomalies such as insertion, deletion, and update anomalies. What are some other characteristics of good database design?
Normalizing the Relational Model for the Student Project and Creating a Normalized SQL Database Patient (patientNo,...
Normalizing the Relational Model for the Student Project and Creating a Normalized SQL Database Patient (patientNo, name, address, phone, dateOfBirth, sex, insuranceCo, policyNo, relationshipToInsured) Appointment(patientNo, apptdate, appttime, reason, staffNo, visitNo) Visit(visitNo, patientNo, visitdate, visittime, duration, reason, visitType, visitCost, staffNo, roomNo) Staff(staffNo, name, title, specialty, address, phone) Availability(staffNo, availDate, startTime, endTime) InsurancePolicy (company, policyNo, insuredName, policytype, medicalCoPay, labCoPay, pharmacyCoPay, startDate, endingDate) DiagnosisMenu(diagCode, diagName) ProcedureMenu(procCode, procName, cost) Room(roomNo, roomType, condition) PrescriptionScript(scriptNo, visitNo, dateWritten, itemPrescribed, quantityPrescribed, directions, numberRefills) LabTest(testNo, prescriptionNo, testype, testDate, testTime,...
Data Modeling and Database Design (Database Concepts, Eighth Edition) The relational model is the most important...
Data Modeling and Database Design (Database Concepts, Eighth Edition) The relational model is the most important standard in database processing today. Why do you feel that this model has continued to be successful in the world of IT? What would happen if large corporations decided to reject this theory, and store their data using a non-relational model? Are there any success stories where this has happened?
design a relational database to cater for the needs of the new bookshop owner as described...
design a relational database to cater for the needs of the new bookshop owner as described in the first question giving examples of tables, attributes, primary and foreign keys. you may assume that suppliers' orders contain more than one line
You are asked to design a relational database for a simple course registration software application for...
You are asked to design a relational database for a simple course registration software application for your school. The relational database must have the following information about the student, the course, and the registration, respectively StudentID, FirstName, LastName, DataOfJoining, and Major CourseNumber, CourseName,InstructorName, StartDate, EndDate, NumberOfCredits ReferenceID, StudentID,CourseID, DateOfRegistration Apply the following constrains while designing the database Each student in the database must be uniquely identifiable Each course listed in the database must be have unique CourseNumber Each course registration...
True or False: Logical database design is the process of modifying the physical database design to...
True or False: Logical database design is the process of modifying the physical database design to improve performance. The two major logical database design techniques are conversion of E-R diagrams to relational tables and data normalization. Multivalued attributes are not permitted in unnormalized data. A many-to-many binary relationship in an E-R diagram requires the creation of a total of three tables in a relational database. A one-to-one unary relationship in an E-R diagram requires the creation of a total of...
Design and implement a relational database application of your choice using MS Workbench on MySQL a)...
Design and implement a relational database application of your choice using MS Workbench on MySQL a) Declare two relations (tables) using the SQL DDL. To each relation name, add the last 4 digits of your Student-ID. Each relation (table) should have at least 4 attributes. Insert data to both relations (tables); (15%) b) Based on your expected use of the database, choose some of the attributes of each relation as your primary keys (indexes). To each Primary Key name, add...
Consider the schemas of the following relational database for a company. The company has different departments...
Consider the schemas of the following relational database for a company. The company has different departments at different cities in different states: employee(employee-id, dept-id, name, street-num, street-name, city, state, zip, salary) department(dept-id, dept-name, city, state) manager(manager-id, employee-id) NOTES: manager-id in the manager relation is a foreign key to the employee relation. employee-id in the manager relation is a foreign key to the employee relation. dept-id in the employee relation is a foreign key to the department relation. An employee belongs...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT