Reputation: 5025
I'm a noob when it comes to mongodb and nosql as a total, but I am very keen on wanting to learn alot, very fast!
So, I've got the situation, that I've got practically the same type, but some are children/inherit from a main type. Now, lets call it a "file". this file can be an image or maybe an exe. If its a an image, it has different fields than a exe file. But generally, they are the same "thing" -> a file.
How would I implement this, while NOT dooing a RDBMS-Style of DB-Schema?
Thank you for any help!
Upvotes: 0
Views: 392
Reputation: 7779
First off, I assume you are not planning on storing the binary file in a database (relational or not). If you plan to do so, MongoDB supports GridFS that can help.
That said, your schema could have the name, and a type attribute that has a type, and given that MongoDB is schemaless, you can add attributes very easily to the document. All these documents can be a part of the same collection.
I work at IGN and we have a similar situation with games, where games with different platforms have different attributes, but at the end of the day they are all "games". Like an iOS game like Angry Birds will not have the same attributes as, say, Modern Warfare.
Best of luck! Hope this helps.
Upvotes: 3