Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is Polyglot Persistence
3.
Databases/ Data Storage Types 
3.1.
SQL Server and Oracle
3.2.
Redis
3.3.
MongoDB
3.4.
Neo4j
3.5.
PostGIS
4.
Frequently Asked Questions
5.
Conclusion
Last Updated: Mar 27, 2024

Polyglot Persistence

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Polyglot refers to a person who can write or speak in more than one language. Neal Ford coined Polyglot Programming in 2006. His idea behind the term was that computer applications should be written in multiple languages taking advantage of different languages for suitably tackling different problems.

What is Polyglot Persistence

Polyglot programming promotes the ideology that efficiency and productivity can be enhanced by using suitable language to solve a particular problem rather than solving all issues with a single language. The ideology, when applied to databases, i.e., the use of different types of databases to store different types of data, is termed Polyglot Persistence.

Let’s understand Polyglot programming with an analogy. When we order food from restaurants, it is generally observed that solid foods are packed in a paper-based or aluminium based box. In contrast, semi-liquid/ gravy food is packaged in plastic storage and drinks in bottles. This can be clearly understood that different types of food are stored in a different containers to resolve the issue of leakage, preserving food, etc. 

Similarly, while building an application, rather than making it a complex architecture by storing all types of data in a single type of database, polyglot persistence promotes the use of different types of databases to store different types of data and keep the complexity of the applications simple. 

In a Polyglot persistence database, a complex problem is broken down into fragments, and these fragments are then solved using different database models. The results are then aggregated into hybrid data storage. 

Let’s understand Polyglot persistence usage with the help of an example. Let's say a simple website that sells some goods has the following needs:

●      Store Current Session Data.

●      Search Bar.

●      Recommendation System.

●      Payment Integration.

We can use different databases to store the following data. Transactions details can be retrieved from Oracle. Store user information and product information on MongoDB and cache on Redis.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Databases/ Data Storage Types 

Different types of databases store different types of data. Let's learn more about commonly used Databases.

SQL Server and Oracle

This type of database stores data in tables with rows and columns. Data is retrieved using Queries. The major drawback of such a database is that it is pretty challenging to scale as the need for storage grows.

Redis

The database stores data in key-value pairs. These databases are primarily used to access a piece of data quickly, i.e. required quite frequently. These databases generally have a key that points to a location (storage location) that holds a piece of data. 

MongoDB

The database stores data in the form of documents. These databases preferably store data in a structured way using JSON/ XML. These are used to store users, and product details and data are retrieved using operations like find(), findOne(), etc.

Neo4j

This database stores data using graph structures, nodes, edges and other graph properties to organise and retrieve data.

PostGIS

This type of database stores spatial data. These databases are commonly used in services related to mapping, etc.

Frequently Asked Questions

  1. What is Polyglot Persistence?
    Polyglot programming promotes the ideology that efficiency and productivity can be enhanced by using suitable language to solve a particular problem rather than solving all issues with a single language. The ideology, when applied to databases, i.e., the use of different types of databases to store different types of data, is termed Polyglot Persistence.
     
  2. What is polyglot architecture?
    The essence of a polyglot architecture is to delegate the decision over which technology stack and programming languages to use to the service developers. There are numerous big technology companies that have evolved to support a polyglot microservices architecture, like Google, eBay, Twitter, and Amazon.

Conclusion

In this article, we have extensively discussed what Polygot Persistence and architecture is all about. We hope that this blog has helped you enhance your knowledge, and if you wish to learn more, check out our Coding Ninjas Blog site and visit our Library. Do upvote our blog to help other ninjas grow.

Happy Learning! 

Previous article
Document Databases in Big Data
Next article
Hadoop: Features,Components,Clusters & Topology
Live masterclass