Export JSON data and load into a Relational Database

久未见 提交于 2019-12-12 16:24:29

问题


Is there a standard way of converting JSON data to relational database with multiple tables? We need to export our data from a MongoDB instance and import them into a Redshift cluster. The only problem is that some of MongoDB fields contain objects and arrays. Redshift cluster accepts CSV so I'm thinking the output would be at least one CSV file for each new table.

I don't need specific implementation. I just wanted to know the concepts on how to efficiently transform the JSON/NoSQL data into relational format.


回答1:


we have our mongo DB which stores JSON data. We wanted to migrated data to Redshift for some querying purposes.

We used mongoexport csv to create csv from mongo table and uploaded it to S3. We created corresponding relational schema in Redshift and used copy commands to load these csv data from s3 to redshift.

We can use java apis to query mongo and create and upload csv to s3. The same can be loaded to redshift.

The real problem is since we use mongo (json) or NoSQL we might have different number of columns for given object which belongs to same table ( as we JSON) , but in Redshift we have fixed number of columns per table So in such cases you need to create all possible columns and load data . For those objects which does not have all columns we can populate null values for them.



来源:https://stackoverflow.com/questions/24878374/export-json-data-and-load-into-a-relational-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!