Answer the question
In order to leave comments, you need to log in
Where can I read/look at the implementation of the normalized data model in C# ASP.NET MVC + MongoDB?
Where can I see / read complex examples of implementing a normalized data model and CRUD operations using C # MVC and MongoDB? Either in Russian or in English. By a normalized model, I mean the following:
Whatever examples I find, the most elementary approach is considered everywhere, something like:
1. We take the mongo driver for sisarpa and implement a wrapper for the collection.
2. Create a new class:
public class Post
{
[BsonId]
public ObjectId PostId { get; set; }
public string Title { get; set; }
public string Text { get; set; }
}
var Post1 = new Post
{
Title = "Title of post",
Text= "Lorem ipusm dolor sit amet."
};
_postCollectionWrapper.InsertOne(Post1);
Answer the question
In order to leave comments, you need to log in
The fact is that MongoDb (and indeed NoSQL solutions in general) does not imply relationships between collections (tables in RDBMS terminology). For the same reason, there are no foreign keys, no transactions (there are only atomic operations), as a rule there is no clear data schema.
This is the price you pay for the ease of horizontal scaling.
For these reasons, many things must be implemented and controlled by the application. The same control of foreign keys and transactions, for example. The implementation of these things largely depends on the business processes and application logic. That is why there is no universal solution and recipe.
In your case, you YOURSELF must write the userId field in contact, access. You yourself must control the correctness of its filling and the relevance of the values.
All this, of course, can be implemented in MongoDB. However, it seems to me that Postgres, MSSQL, etc. are more suitable for your task.
I advise you to look: https://habrahabr.ru/post/259219/ https://habrahabr.ru/post/260291/
Have you ever thought that if no one writes about it, then most likely no one does it?
What for you monga? Stupid to be? Use MSSQL, and mongu only for some separate entity, if it really needs to be there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question