Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8517017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:35:06+00:00 2026-06-11T05:35:06+00:00

We are now choosing a database for a project. The candidates are mongodb and

  • 0

We are now choosing a database for a project. The candidates are mongodb and postgres. Our users need to define conditional logic, e.g. user defines conditions (as strings) “x happens”, “y leaves” etc, and can then concatenate them to conditions “if x happens AND (y leaves OR z comes)…”.

Doing it in a single json document seems much more readable than in a relational database.

Do you see any way to model this reasonably in postgres? I know postgres 9.2 will support json but the querying capabilities seem clunky.

In mongo the verbs (“x happens”) will be duplicated between the conditions. A verb update will affect multiple rows. Do you see a problem here?

EDIT: the mongo documents may look like this:

{
  "where": 
     [1,"x happens"],
     "and": 
     { "where": 
            [2,"y leaves"], 
               "or": 
            [3,"z comes"]
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:35:08+00:00Added an answer on June 11, 2026 at 5:35 am

    Ok, in this area PostgreSQL and MongoDB are going to be fairly different and yet fairly similar in how you have to think about this. The big thing is get away from the strict relational idea. Your choices are object-relational or document-oriented. I would choose the former because I am more comfortable with it.

    The key thing is that a you have to be able to reduce your conditions to bools that are definable on the fly. If you do this in PostgreSQL you will have some programming to do. The tradeoff is that you get ad hoc reporting that would be painful to do in MongoDB.

    The key thing you can do in Postgres is model derivative data. So the key thing in PostgreSQL to make this manageable is to use table methods to check the constraints at run-time. To create a table method in PostgreSQL use a form like this:

    CREATE OR REPLACE FUNCTION method_name(table_name) RETURNS return_type ....
    

    You may find this helpful with more examples: http://ledgersmbdev.blogspot.com/2012/08/postgresql-or-modelling-part-2-intro-to.html (yes, that’s my blog).

    The fact is that you can build some extremely sophisticated quasi-relational models on PostgreSQL and so I wouldn’t rule it out in that regard. The question is whether you need the relational side, for ad hoc queries and reporting over sets of objects. If you do then Mongo alone won’t cut it and you could either export from Mongo into Postgres or do things in PostgreSQL.

    This isn’t saying that PostgreSQL is the answer. If you never need to add new query types, maybe Mongo is better. However this is one of those cases where you really want to be using every advanced feature Pg offers you that is useful in your case if you are going that route.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have experience in database development, so I need your suggestions in choosing
I've live project experience with CodeIgniter and Cake PHP. However now I need to
We are investigating on choosing a nosql database for our web service. We have
Our masters thesis project is creating a database schema analyzer. As a foundation to
Every file type associated with its specific icon . Now if i am choosing
now i'm working on a project for creating audio unit instrument that provide the
Now getting error Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT
I'm now working on Sample login application in which user can login with their
Pretty soon now, we're gonna need to develop a GUI for creating configurations (more
Is it possible to replicate a mysql database by choosing only the tables you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.