S
S
Snitch2016-02-12 14:24:59
MongoDB
Snitch, 2016-02-12 14:24:59

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:
data-model-normalized.png
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; }
}

3. And we save an object of this class using a wrapper for the collection:
var Post1 = new Post
{
  Title = "Title of post",
  Text= "Lorem ipusm dolor sit amet."
};
_postCollectionWrapper.InsertOne(Post1);

4. End of the guide.
There are people asking questions similar to mine. And they are answered: are you really a fool, mongo is a document-oriented storage, use nested documents. So my question is NOT about nested documents. Please answer on the topic of the question. Maybe there are some ORM / ODM solutions. Maybe there are some articles or books. Maybe something else that I don't know.
I read the documentation of the monga itself and specifically the driver for C # several times, but due to a lack of experience and knowledge in programming, I can’t do anything. It is especially unclear to me what steps and in what sequence the C # object (POCO) passes when saving it to the mongi collection. And how to manipulate/redefine these steps or wedge into them. Plus, I'm trying to do all this on MVC 6. According to which, too, now what the hell can you find, because of the novelty. For example, how to file a custom ModelBinder.
Maybe there is a person rummaging around in C # .NET MVC / MongoDB, to whom I can sometimes ask questions (via Skype for example). I will be glad for any help.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Artem Dudnik, 2016-02-18
@schart

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/

R
RouR, 2016-02-18
@RouR

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.

F
Flaksirus, 2016-02-18
@Flaksirus

I don’t really understand why a custom BroughtInstaller is needed, when the driver has the most powerful attributes that fully describe what to do with the module and how. And in general the task of "the normalized model" is not clear to me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question