Aleem
Aleem

Reputation: 3291

How to store tree base data into Data base?

I am developing an application of iphone which is navigation based, and i am showing data on first View Items then on second View Sub Items and so on. So my question is that what will good approach to save this on Data base (sqlite).

Upvotes: 0

Views: 74

Answers (2)

Amit Singh
Amit Singh

Reputation: 8383

i am not an expert in this field but you can do it like this ... now that you said all you data can be represented something like tree...

  1. Find all the objects that will be leaf of your tree make those objects as a table in DB, (please keep in mind that you make table only for objects that have different structure not because they have different values)

  2. Repeat above step for one level above until you reach top

Eventually you will find that you just got your DB.

To be more precise you need to study DBMS

Upvotes: 0

ader
ader

Reputation: 5393

Keep this simple. Each object/View has it's own ID and at least one parent ID. This will ensure your data can represent trees of any depth and any complexity.

Upvotes: 1

Related Questions