Modelling document sharing permissions with NoSQL I'd like to use NoSQL databases for the first time and was going to use MongoDB.  I have a project where an employee with @employeed_id can go to a web app and get a list of documents that he can read.  If this were a relational database, I might begin my SQL statement like this to fetch all the documents he has read access to (I'll explain in plain english what I'm trying to achieve next):

SELECT * FROM t_document
WHERE EXISTS (
    SELECT 1 FROM t_user
    WHERE t_user.user_id = t_document.author_id
    AND t_user.user_id = @employee_id
) OR EXISTS (
    SELECT 1 FROM t_user
    WHERE EXISTS (
        SELECT 1 FROM t_document_share
        WHERE t_document_share.user_id = t_user.user_id
        AND t_document_share.read_access = 1
    )
    AND t_document.company_id = t_user.company_id
    AND t_user.user_id = @employee_id
) OR EXISTS (
    SELECT 1 FROM t_user
    WHERE EXISTS (
        SELECT 1 FROM t_document_group_share
        WHERE t_document_group_share.read_access = 1
        AND EXISTS (
            SELECT 1 FROM t_user_group
            WHERE EXISTS (
                SELECT 1 FROM t_user
                WHERE t_user.user_id = t_user_group.user_id
                AND t_user.user_id = @employee_id
                ...
                ...
            )
        )

    )
)


Essentially, what I'm saying is get me all documents where at least one of these conditions apply:


I am the author of the document
the document has been shared with me, I have read access, and the document is owned by a company that I am employed at
the document has been shared with a group that I belong to.  The group has read access to the document.  Both I, the group, and the document belongs to the same company


After some quick online research, I read opinions that my use case is not meant for NoSQL.  All these sub queries (and potentially joins) to investigate relationships between different entities is cumbersome to do in NoSQL.  So my question is, can someone confirm if using NoSQL to solve my problem is like trying to make a fish climb a tree?  If so, then I will look for other projects to practice NoSQL on
I guess I'll answer my own question until someone gives a better answer.

When the relationships between entities are known and important to preserve, these relationships are costly to implement and enforce with a NoSQL database.  Looking at the relationships between entities is easy to do with a single SQL statement that is comprised of more sub queries and joins.  Doing something similar with lookups or other javascript/json programmatic instructions is cumbersome and likely to be substantially more computationally intensive when compared with a relational database/SQL approach.

Hence, using a NoSQL database in a situation where the relationships between many entities are known, important to preserve and important to enforce, is like using a steak knife to chop down a tree.  It can be done, but there are better tools for the job.