I’m new to MongoDB, I’m working with .net core 2.2 and I’ve just added a library to my project to manage archives that, imho, are not kind to be managed with a sql db.
The problem I would like to solve with MongoDB is (this is just an example) to archive the successive positions of many users to create something like an history of their positions.
Users are identified by an ID, while the posiion is just a bunch of bytes (8) to be archived together with a date information (an int).
So mainly the strucure of the collection UserPositions I want to create is this:
public class Position {
public byte[] PositionInfo = new byte[8];
}
public class DatePositions: Dictionary <int, Position> {}
public class UserPositions {
public int UserId;
public DatePositions UserPositions;
}
I wonder if the creation of collections of UserPositions is the best way to use Mongo.
Consider that this information is updated once a day for all the users and it’s retrieved only for a single user per query.
A brilliant idea I had is to create a single collection for each user, a collection named Position_User_Id such that I can add a date/position to the collection without having to retrieve the entire UserPositions object, adding a new position and update it.
In this case I would have many position collections, in which the Position class is modified adding a date to the class:
public class Position {
public int Date;
public byte[] PositionInfo = new byte[8];
}
I apologize if this request is very basic, but after some reading (I’m not a very skilled programmer) I still wonder if I catched the philosophy of the MongoDB using.