Michael Lambertz
Michael Lambertz

Reputation: 21

Complex and multiple connected database relations in MongoDB

I am currently trying to model a MongoDB database structure where the entities are very complex in relation to each other.

In my current collections, MongoDB queries are difficult or impossible to put into a single aggregation. Incidentally, I'm not a database specialist and have been working with MongoDB for only about half a year.

To keep it as simple as possible but necessary, this is my challenge:

I have newspaper articles that contain simple keywords, works (oevres, books, movies), persons and linked combinations of works and persons. In addition, the same people appear under different names in different articles.

Later, on the person view I want to show the following:

In my structure I want to avoid that entities such as people occur multiple times. So these are my current collections:


Article
id
title
keywordRelations


KeywordRelation
id
type (single or combination)
simpleKeywordId (optional)
personNameConnectionIds (optional)
workIds (optional)


SimpleKeyword
id
value


PersonNameConnection
id
personId
nameInArticleId


Person
id
firstname
lastname


NameInArticle
id
name
type (e.g. abbreviation, synonyme)


Work
id
title

To meet the requirements, I would always have to create queries that range over 3 to 4 tables. Is that possible and useful with MongoDB?

Or is there an easier way and structure to achieve that?

Upvotes: 0

Views: 127

Answers (0)

Related Questions