Re: J2EE: Storing hierarchical data
- From: Jon Martin Solaas <jonmartin.solaas@xxxxxxxxxxxx>
- Date: Wed, 28 Dec 2005 12:24:05 +0100
Florian Lindner wrote:
Hello,
I'm searching for the best concept of how to use and save hierarchical data
in a J2EE server.
I have a structure like a PC file system with meta data. There a folders and files of different types. Every object have data like permissions, date and author. And they have type-specific data fields like resolution (of an image type) or location (of an meeting type) or ingredients (of an recipe type).
What is the best way to store that kind of data in an J2EE web application?
What database is recommendable? What concepts of persistance? Or not using
managed persistance and do it manually?
Thanks for all ideas!
Florian
The most straight forward way would be to store data in a normal sql database.
One table for the hierarchy
create table dir ( dir_id number, parent_dir_id number, dir_name varchar2(255), dir_type number, dir_metadata varchar2(255) )
create table file ( file_id number, dir_dir_id number, file_type number, file_metadata varchar2(255) )
Then you have a hierarcy defined in the table dir, and each file belongs in exactly one dir (unless you make a N:N relationship ofcourse). You could also store information about type and metadata in separate tables or whatever suits your needs.
Next would be to select a persistence technology. This would work with most known technologies and the easiest would probably be to use the same as you use for other relational data in your application. Straight jdbc, Hibernate, CMP ... it's your choice. CMP has some features to manage relations automatically for you, and I'm sure Hibernate has some features to help you out with the relational/hierarchical stuff here as well.
This method would give you all the pros and cons that sql databases always do, transactions and so on. I don't know how you intend to use your hierarcy so it's impossible to tell if this is useful for you.
One alternative for storing hierarchical data that sometimes comes up is using Prevayler (you'll find it at google), which is sort of a very fast in-memory hierarchical database. I've never tried it, but it's supposedly very fast, and has different characteristics from a normal, relational dbms.
.
- References:
- J2EE: Storing hierarchical data
- From: Florian Lindner
- J2EE: Storing hierarchical data
- Prev by Date: Re: Advice needed: Hibernate and MySQL?
- Next by Date: How to make an association between a class and an interface w/ hibernate?
- Previous by thread: Re: J2EE: Storing hierarchical data
- Next by thread: JDBC+SSL?
- Index(es):
Relevant Pages
|
|