jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Edelson <jus...@justinedelson.com>
Subject Re: data integrity (mix:referenceable)
Date Sat, 21 May 2011 14:58:04 GMT
Keep in mind that mix:referenceable nodes are meant to be the *target*
of a REFERENCE or WEAKREFERENCE property. You seem to be thinking of
using them as the *source* which is not the case.

In the case you're describing, I would have a node at
/content/top_10_articles/2011/05 with a multi-valued STRING property
where each value is the path to an article node. My rendering code
would loop through the values of this property, getting the
corresponding node from the repository and doing something with it (in
the case of Sling, this would probably be done with a sling:include
tag and a selector script). The rendering code would be able to deal
with the situation where a path refers to a node which no longer
exists on the chance that a referenced article was deleted.

Instead of a multi-valued STRING property, you could alternatively use
PATH, REFERENCE or WEAKREFERENCE as the property type, but those carry
additional overhead. In the case of REFERENCE, the repository would
enforce referential integrity thereby preventing the deletion of a
"top 10 article". I doubt you want this.

In general, I would avoid using a query for this.

Justin

On Fri, May 20, 2011 at 7:48 AM, sam lee <skynare@gmail.com> wrote:
> Hey,
>
> I store articles in JCR as nt:unstructured.
>
> I need to have a list of "top 10 articles". The list is curated. The list is
> archived monthly.
>
> What's a proper way of storing "top 10 articles" ?
>
> In relational database, I would create top_10_articles(article_id foreign
> key, archive_date)  table.
>
> I could create a node,  /content/2011/05/top_10_articles, that has child
> nodes that are mix:referenceables referencing actual article
>  (/content/article/foo/bar). Would mix:referenceable keep my data
> consistent? For example, removing /content/article/foo/bar should delete the
> child node under top_10_articles. Also, modification of
> /content/article/foo/bar should be reflected on the child node of
> top_10_articles.
>
> Or, should I just put  isTopArticle boolean in every article and query for
> articles that has isTopArticle  (and filter out matching date range for
> monthly archive)?
>

Mime
View raw message