DEV Community

Discussion on: How do you handle many-to-many relationships in Mongo?

Collapse
 
biztux profile image
George Embrey • Edited

The ONLY truly viable way to ensure the integrity of data in Many to Many relationships is to use database engines which are designed to correctly handle foreign key constraints, RDBMs are the typical way to do this, many Modern RDBMs also handle JSON data extremely well and can store Documents in JSON columns whilst still maintaining full referential integrity. (Yes there are some who would suggest doing it in code, most who do so have never had to fixup the data messes this can and often does cause).

PostgreSQL (Amazon Redshift), MySQL 8 (Amazon RDS / Aurora MySQL 8), SQL Server (Amazon RDS SQL Server / Azure SQL Database), these three are very widely used and each have JSON functions which enable many of the functions of NOSQL databases to be implemented within an RDBMs.