Needs advice
on
MongoDBMongoDB
and
PostgreSQLPostgreSQL

Hi everybody, I'm developing an application to be used in a gym setting where athletes fill out a health survey, and coaches can analyze the results. However, due to the dynamic nature of some aspects of the app and more static aspects of the other, I am wondering if/how I would integrate MongoDB with my existing PostgreSQL database. I would like to store things like registrations, license information, and club information in Postgres, while I am thinking about moving things like user surveys, logging, and user settings information over to MongoDB. Some fields on the survey are integers, some large blocks of text, and some are arrays. My thought is, if I moved that data to MongoDB, it would give us greater flexibility in terms of adding and removing fields and data to them, and it would scale a lot easier than Postgres. Not to mention it will be easier to organize that kind of data. Is that overkill or am I approaching this issue the right way? Thank you!

READ LESS
8 upvotes·572.4K views
Replies (4)
Founder & CEO at BaseDash·
Recommends
on
PostgreSQL
at

How are you managing your PostgreSQL schema? It doesn't have to be hard to add or remove fields. We're working on a SQL database client at BaseDash that lets you add/remove columns in a couple clicks.

If you decide to migrate some of your data to MongoDB, you can definitely manage the two databases in parallel. For any records that need to be linked, you can treat it just like a foreign key by creating a column that points to an ID in the other database. For example, you might store user settings in MongoDB, and include a UserId field that points to your User record in your Postgres database.

READ MORE
4 upvotes·1 comment·399.1K views
BrockHerion
BrockHerion
·
May 7th 2020 at 3:47AM

Thank you, this helps me quite a bit. I am using DataGrip from JetBrains to manage the Postgres schema. It isn't terribly difficult to change or add columns too, just more of an inconvenience on my end. My goal is to let the my client to easily be able to add and remove questions along with managing the type of question being proposed. I feel that in Mongo, it's easier to manage changes to a schema and will give them a greater degree of flexibility in changes they want to make in the future.

·
Reply
CTO at Merryfield·
Recommends
on
PostgreSQL

You can have your cake and eat it too. If you really need the flexibility of a document store, Postgresql's JSONB support allows you to mix and match relational data and document data within the same database/table. You can just as easily run analytical queries against JSONB data in Postgresql as you can against "normal" relational data. MongoDB comes with a significant operational overhead and cost (hello replica sets), so unless you really need MongoDB's sharding capabilities (which you shouldn't until you get to extreme scaling numbers), then just stick with Postgresql and use JSONB where you need it.

READ MORE
7 upvotes·398.2K views
View all (4)
Avatar of Max Musing

Max Musing

Founder & CEO at BaseDash