'Structure the same RDBMS Tables into MongoDB
There is a requirement to convert the current structure of MYSQL to MONGODB. We have several tables in MYSQL which are interlinked via primary and foreign key sample DB Model as shown below. Can you share some insights how can we convert the same structure to MongoDB without disturbing the contraints. If possible how to convert the same sturcture in MONGODB with below tables example can anyone share please. Thanks in advance.
Solution 1:[1]
It greatly depends on how you are using the data. Since Mongodb is NoSQL, a database of documents, you can see each of your table as a collection of documents.
A collection of jobs
A collection of job_type
A collection of account
A collection of account type
From my perspective, all of your tables can be converted into individual collections, Unless you have very unusual queries.
The only thing if you want to reference one collection to another, then you should probably include the reference to the collection to ease querying and reduce lookup time.
For example, in your candidate_profile, if you want to retrieve the job_type, you should include a job_type_id field in your candidate_profile.
If you want to easily find which job the candidate has, you should add a job_id field to the candidate_profile
If you don't, then your query becomes complicated and messy.
You should probably create the database with the collections then see whether it meets your requirement.
PS: I converted my application from mysql to mongodb as well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

