tag:blogger.com,1999:blog-7603905557430854104.post3628323040588948046..comments2012-08-23T00:53:51.056-07:00Comments on Nice One!: From OR to CR modeling - HierarchiesChrigelhttp://www.blogger.com/profile/05227615949751525227noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-7603905557430854104.post-85446941274159684602008-04-03T08:11:00.000-07:002008-04-03T08:11:00.000-07:00Very good info, makes a lot things clearer!I had t...Very good info, makes a lot things clearer!<BR/><BR/>I had to spontaneously think about "duck typing" while reading your comment. Then you even wouldn't care about the type of the node as long as the required information is available...<BR/><BR/>And yet another connection between JCR and dynamic languages...Chrigelhttps://www.blogger.com/profile/05227615949751525227noreply@blogger.comtag:blogger.com,1999:blog-7603905557430854104.post-58304238758005976682008-04-03T06:27:00.000-07:002008-04-03T06:27:00.000-07:00The nice thing about JCR is that the content hiera...The nice thing about JCR is that the content hierarchy is quite flexible (unless you explicitly constraint it with strict node types), so you can evolve the structure as your application grows.<BR/><BR/>Assuming no other use cases than "manage information about books", I'd start with something simple, perhaps even just the /books tree with @author and @category as simple string properties with no need for the separate /authors and /categories trees.<BR/><BR/>Then as your application evolves and you add more use cases you can introduce new concepts like structured author information, etc. Also, if it turns out that some other hierarchy seems more natural, it should be no problem to reorganize the content tree.<BR/><BR/>To best achieve this flexibility, my rule of thumb is to always use the type of a node rather than it's location (path) to decide how it should be handled. This way you can decouple much of the application logic from the overall structure of the content model. For most of the code that manages books it should make little difference whether the book nodes are located below /authors, /categories, or /books.Unknownhttps://www.blogger.com/profile/13534790403556316268noreply@blogger.comtag:blogger.com,1999:blog-7603905557430854104.post-43899342964331612812008-04-03T05:53:00.000-07:002008-04-03T05:53:00.000-07:00Ok, I see, I think it is a matter of taste: the sa...Ok, I see, I think it is a matter of taste: the sample is more or less a "flat out" version (I do not like the naming, it is wrong), where the "books" hierarchy is depending on both the "authors" and "category" hierarchy. <BR/><BR/>Well, another question arises: should you design your content model with only one use case (or application) in mind? Or should you consider your model as beeing self-contained? Imagine writing both a publisher and a bookstore application ...Chrigelhttps://www.blogger.com/profile/05227615949751525227noreply@blogger.comtag:blogger.com,1999:blog-7603905557430854104.post-28694548373401118732008-04-03T00:28:00.000-07:002008-04-03T00:28:00.000-07:00Here's an attempt using _ for indentation:/my:cont...Here's an attempt using _ for indentation:<BR/><BR/>/my:content<BR/>__/authors<BR/>____/K<BR/>______/Stephen King<BR/>__/categories<BR/>____/Thriller<BR/>__/books<BR/>____/1987<BR/>______/Misery<BR/>______ @author -> Stephen King<BR/>______ @category -> ThrillerUnknownhttps://www.blogger.com/profile/13534790403556316268noreply@blogger.comtag:blogger.com,1999:blog-7603905557430854104.post-42148683882496166022008-04-03T00:24:00.000-07:002008-04-03T00:24:00.000-07:00Hi JukkaCongrats & thx for the first comment :). U...Hi Jukka<BR/><BR/>Congrats & thx for the first comment :). <BR/><BR/>Unfortunately the comments dont allow nice formatting via e.g. pre tags. Would you mind giving me a hint about the level of the respective nodes in your proposed model?<BR/><BR/>ThxChrigelhttps://www.blogger.com/profile/05227615949751525227noreply@blogger.comtag:blogger.com,1999:blog-7603905557430854104.post-18976771911563971462008-04-02T13:26:00.000-07:002008-04-02T13:26:00.000-07:00The optimal model depends on what your application...The optimal model depends on what your application is primarily designed for.<BR/><BR/>If you're a publisher that manages books by author (i.e. the primary way to look at the content is by author), then you'll want a <author>/<book> hierarchy.<BR/><BR/>If you're a book store that manages books by category, then a <category>/<book> hierarchy is probably better.<BR/><BR/>Or you could go with something like this that gives you easy views by author, category, and year:<BR/><BR/>/my:content<BR/> /authors<BR/> /K<BR/> /Stephen King<BR/> /categories<BR/> /Thriller<BR/> /books<BR/> /1987<BR/> /Misery<BR/> @author -> Stephen King<BR/> @category -> ThrillerUnknownhttps://www.blogger.com/profile/13534790403556316268noreply@blogger.com