mongodb schema design advice I have a users index which has fields like id, email, password, etc. A user can see all other users except the ones who had blocked him. I want to design a database schema for this problem.

So I'm using MongoDB and I have these two tables.

Users

id   email   password
01   a@b.co  123
02   b@c.co  XYZ



now, I need a way to store the block relations information. If x has blocked y then y can't see x on the user's list.

If I add an array in user y which contains all user id who has blocked them so would it be a good solution? or is there any other alternative?

Users

id   email   password   blockedBy
01   a@b.co  123        []
02   b@c.co  XYZ        [01, 07]



now, I'll show all the users to user 02 except 01 and 07.
If the information fits inside the record, go for it.

But remember that there is a limit to it, if you limit the block to something like 1000 users, should be fine.

When you are not in the position to define limits, then you should create another collection to handle this relation.