I need to make an app in Java that must add in a database all the files (with folder structure) from a hard drive. I need to add the metadata of this files as well.

What it will be the best aproach ? Using SQLite with multiple tables or Neo4j ??

If you plan on chasing around a lot of parent-child links, RDBMS get's a bit cluky due to the impedance mismatch between the relational model and the inherent hierarchical nature of the file system entries. I would personally go with Neo4J.

I tend to agree with s.o.s about the clunky nature of SQL to model such hierachical structures. It can be done of course, but the file data would have to be BLOBS if you want the file data in the database. Depending upon their sizes, that could be an issue as well. All the directories could be in a single table with self-joins to reference their parents, and the containing directory in the file table would be a foreign key to the directory table. Since multiple directories, even in the same path, can have the same name, you would need another field for the primary directory key - ditto the files.

So, doable, but complex. Personally, I'm not familiar with Neo4J. I'll have to do some research to see if that would be a better option, but at this point I'll take s.o.s's opinion about that.

Member Avatar for diafol

Not a javaist, but there may be an alternative to the self-join model (adjacency model) - the nested sets model. Here's a link:

http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

I've had a few discussions about this over on the PHP forum. If you're interested, I can see if I can dig them out as I created a couple of visuals that may help. However, I only envisaged storing structure, not files too. It could get messy, heh heh.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.