views:

194

answers:

1

I was wondering about the following two options when one is not using SQL tables but ORM based DBs (Example - when you are using GAE)

Would the second option be less efficient?

Requirement: There is an object. The object has a collection of similar items. I need to store this object. Example, say the object is a tree and it has a collection of leaves.

Option 1: Traditional SQL type structure:

  • Table for the Tree (with TreeId as the identifier for a row in the Table.)
  • Table for the Leaves (where each leaf has a TreeId and to show the leaves of a tree, I query all leaves where the TreeId is the Id of the tree.)
  • Here, the Tree structure DOES NOT have a field with leaves.

Option 2: ORM / GAE Tables: Using the same example above,

  • I have an object for Tree where the object has a collection (Set/List in Java/C++) of leaves.
  • I store and retrieve the Tree together with the leaves (as the leaves are implemented as a Set in the Tree object)

My question is, will the second one be less efficient that the first option?

If so, why? Are there other alternatives?

Thank you!

A: 

It would be better to use Hibernate(for java) or other ORM framework than ORM db.
1. orm db's are mostly amateur.
2. no one appreciates it. You will be much better specialist if you know PostgreSQL with orm framework than just some orm db.
3. there are many standards in the world of rdbms. no standards in orm dbs.
4. rdbms support and community make this choice safer in long term.
5. effeciency is a tricky question. almost 80% sure that if you want to find row with "name = 'Alex'" it will be faster in rdbms than in orm db, cuz orm db will need to unpack object for this operation.
PS: i understand, my post is almost offtopic, but i think it contains some good stuff to think about.

foret