Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When to nest objects and when to use references

 
Sebastian Barszczewski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

i am new to the whole nosql topic and i was wondering where the differences are between designing classic sql schemas and nosql schemas. I am especially interested in when should i use references and when should i use nested objects? What are the experiences concerning this decision?.

Regards,
Sebastian
 
Askar Akhmerov
Greenhorn
Posts: 20
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sebastian,

from what I've learned about NoSQL, the rule of thumb is : inline everything in the document as long as you don't really need a reference to another collection.
In terms of webapp I would suggest using separate document entity for a screen accessible by user.

Example: Portal page. It has a list of portlets which will probably be a DbRef, however each such page probably has static data like user information, terms and conditions,etc. which can be inlined.

You should also keep in mind that DbRef's will not get updated automatically upon top level entity update. You will have to implement somthing like deep copy mechanics in order to persist that information and always have 1 state of an entity.
 
Sebastian Barszczewski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Askar Akhmerov wrote:
You should also keep in mind that DbRef's will not get updated automatically upon top level entity update. You will have to implement somthing like deep copy mechanics in order to persist that information and always have 1 state of an entity.


Thats a good hint. Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic