0

Please see the DDL below from my CQRS write database:

CREATE TABLE Offer (ID uniqueidentifier NOT NULL, Description varchar(50), Image varbinary(max), primary key (ID))
CREATE TABLE Person (ID uniqueidentifier NOT NULL, Name varchar(50), OfferID uniqueidentifier, FOREIGN KEY (OfferID) 
REFERENCES Offer(ID), primary key (ID))

Notice that a Person can have one offer and an offer can have many persons (there are about two million people and two offers).

Say I wanted to store this information in a NoSQL database like MongoDB for performance on the read side. Should the image be embedded for every person? This seems like a complete waste of space as it would mean that there are two images embedded millions of times.

Alternatively I believe I could use references (https://docs.mongodb.com/manual/reference/database-references/). However, my research is telling me that references should be used in very specific circumstances as you lose the benefits (performance) of a NoSQL database. What is a suitable way to approach this?

I have come across this question here: mongoDB design - to embed or not to embed, which states that embedded resources should be used for one to many relationships. However, this would mean storing the image in every document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.