using document oriënted database mongodb and the Object Document Mapper (ODM) morphia
Lets say we have 3 different classes; Object
, Category
and Action
.
These object are all stored in the collections; objects, categories and actions.
Category
and Action
are references of Object
@Entity("objects")
public class Object {
@Id
@Property("id")
private ObjectId id;
@Reference
private Category category;
private Action action;
...
}
@Entity("categories")
public class Category {
@Id
public String categoryTLA;
public String categoryName;
...
}
@Entity("actions")
public class Action implements BaseEntity {
@Id
public String action;
public int accesLevel;
...
}
The documents with the current implementation are stored like:
Is it possible to store 2 different Objects, in this case Category
and Action
, in one collection, like shown in the next example? Both with their own identification!
Yes, you can have multiple collections within a database in MongoDB.
MongoDB supports no more than 100 levels of nesting for BSON documents. Each object or array adds a level.
MongoDB uses Binary JSON and MQL as an alternative to SQL. BSON allows for data types such as the floating-point, long, date, and many more that are not supported by regular JSON.
Large objects, or "files", are easily stored in MongoDB. It is no problem to store 100MB videos in the database.
yes. but probably you need to add field "documentType" to any document to distinguish documents
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With