DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Translate SQL Queries to MongoDB

How to Translate SQL Queries to MongoDB

Alec Noller user avatar by
Alec Noller
·
Jun. 12, 14 · Interview
Like (0)
Save
Tweet
Share
8.44K Views

Join the DZone community and get the full member experience.

Join For Free

We've heard plenty of reasons one might transition from a relational database to a NoSQL solution like MongoDB, but there can be a learning curve. Developers looking to switch over to (or just do some side work with) MongoDB might be interested in Max Seiden's tips on how to translate SQL queries to MongoDB. In Seiden's case, MongoDB is a "log analytics engine" running alongside PostgreSQL, but his use case has still produced a number of useful techniques.

Specifically, Seiden runs through an assortment of SQL needs and demonstrates their usage in MongoDB. For each, he also gives a brief explanation of what's interesting about the translation and about the queries themselves. For example, he looks at the following topics:

  • Counts & Distincts
  • Counts with Predicates
  • Projections with Predicates
  • Group by remote IP with URLs and Predicates
  • Group by remote IP with Distinct URLs and Predicates

And Seiden even gathered some useful, real-world insights with this set-up. He was able to discover "petty attacks" on his website using a modified version of one of his "distinct" queries, for example.

There are, of course, drawbacks and caveats, but overall, Seiden's SQL-to-MongoDB examples provide a fantastic look at how the two database options relate to each other. Read the full article to see how it's all done.

Database Relational database MongoDB sql

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Efficiently Computing Permissions at Scale: Our Engineering Approach
  • Explainer: Building High Performing Data Product Platform
  • 5 Tips for Optimizing Your React App’s Performance
  • Easy Smart Contract Debugging With Truffle’s Console.log

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: