Reputation: 1496
I was asked at work to switch from SQL Server to Mongo DB.
I am doing good understanding the no-sql concept, but I am having a hard time understanding a few things.
The current application works in Angular 10. This application calls a set of .NET APIs to query the SQL Server database and returns all needed Json files for the application to operate.
My concern is regarding specific queries I perform today at the server side, as this one:
WITH IH AS (SELECT SponsorPL, plid
FROM dbo.PL
WHERE (plid = 154)
UNION ALL
SELECT A.SponsorPL, A.plid
FROM dbo.PL AS A INNER JOIN
IH AS B ON B.SponsorPL = A.plid)
SELECT TOP (100) PERCENT IH_1.plid, PL_1.userid
FROM IH AS IH_1 INNER JOIN
dbo.PL AS PL_1 ON IH_1.plid = PL_1.plid
WHERE (IH_1.plid <> 154)
This particular recursive query retrieves, for user 154, his entire upline (his sponsor) and returns the records as on the attached image.
Can these types of queries be done on MongoDB?
Thanks.
Upvotes: 1
Views: 120
Reputation: 10737
MongoDB as noSQL distributed document store differs significantly from RDBMS SQL databases , you need in general to denormalize the relational model and transform it to document model avoiding such type of join queries as much as possible , in case you cannot avoid it, you can still use aggregation / $lookup to achieve similar results...
Upvotes: 1