-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Best way to map categorization (Category, Subcategory & Tag)
PostPosted: Sat Apr 08, 2017 8:19 am 
Newbie

Joined: Wed Apr 05, 2017 2:10 am
Posts: 4
I am in the process of mapping the categorization which would include:

- Categories (having one or more subcategories)
- Subcategories (having one or more parent categories, and one or more tags as children)
- Tags (these are further segmentation of categorization, and would have one or more (usually more) parent subcategories).

Each of them would have the following attributes:
- Name
- Slug (for SEO purposes)
- EntryCount (entry = post, number of entries/posts that have assigned that cat/subcat/tag to it)
- ParentCount (for example, how many parent categories this subcat has)
- ChildCount (how many children...)
- Subcategories would have both ParentCount and ChildCount

I'm thinking about a base class, something like Taxonomy - which may hold the common attributes?

Anyway, does anyone think there should be inheritance involved?


Top
 Profile  
 
 Post subject: Re: Best way to map categorization (Category, Subcategory & Tag)
PostPosted: Sat Apr 08, 2017 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You can map the Toxonomy base class as @MappedSuperclass so that the inheritance module is materialized in the DB since it might not be very useful for polymorphic queries.


Top
 Profile  
 
 Post subject: Re: Best way to map categorization (Category, Subcategory & Tag)
PostPosted: Sat Apr 08, 2017 1:25 pm 
Newbie

Joined: Wed Apr 05, 2017 2:10 am
Posts: 4
vlad wrote:
You can map the Toxonomy base class as @MappedSuperclass so that the inheritance module is materialized in the DB since it might not be very useful for polymorphic queries.


I will certainly try to implement it that way and see how it goes. Thanks for your input.

At the moment, I've proceeded with @ManyToMany (but actually two @OneToMany, as you suggest in your book) mapping between:

- Entry/post and Category
- Category and Subcategory,
and finally (not yet there),
- Subcategory and Tag

Do you think such a solution would be acceptable or is it too much classes/tables for what I need to achieve?


Top
 Profile  
 
 Post subject: Re: Best way to map categorization (Category, Subcategory & Tag)
PostPosted: Sat Apr 08, 2017 3:33 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Don't worry about a few extra classes if they enable you to get better performance and much more flexibility


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.