简体   繁体   中英

PostgreSql or MongoDb for the data in JSON received from REST API

I'm creating a web application which will communicate with REST API which returns data in JSON. That data can be converted into relational data, of course, when I fetch it to store into a db which happens to be PostgreSql. But I'm thinking about using MongoDb instead because working with JSON is more natural for MongoDb.

Your thoughts, should I use MongoDb instead for that reason?

What the best option may be for you can depend on several factors:

  • How often are you going to poll the API?
  • How frequent are you going to be inserting into the DB?
  • How often are you going to read from the DB?
  • How fast will the data grow?
  • What is the structure of the actual data?

MongoDB horizontal scales very well meaning that if you are going to be polling the API frequently and inserting large volumes of data into your DB then it is relative easy to implement sharding and fire up another Mongo instance on another server. Difference between scaling horizontally and vertically for databases

Inserting JSON data into MongoDB would probably be simpler than converting it to a relational format and maybe doing several inserts where (assuming the JSON is formatted properly) you could just do a single insert. Or use mongoimport to import many JSON documents at once. If the API data changes quite often for instance new columns, then in a relational database you will have to create the columns using ALTER TABLE, whilst in MongoDB it will just store the JSON document.

If you want to know more info about MongoDB they do offer free online courses. The courses are 7 weeks long , Each week they release new video lectures and a new assignments which take a couple of hours to get through. https://university.mongodb.com/courses/catalog

There is one use case worth checking if you have any aggregation of data fields inside json structure . That is a use case which might need stickiness to RDBMS or in an advanced state maybe an OLAP store.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM