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.