My understanding is SU wants to store a linked list. The way that the Palm
databases work means that you cannot store the pointers. However it is
possible to store the unique ids. So replace the variable refRec in the
database as the unique of the sub record.
I had to do the similiar. I was saving directory structures. I save it in a
sorted order:
"/"
"/Doc"
"/Doc/Dir1"
"/Doc/Dir1/file1"
"/Doc/Dir1/file2"
"/Doc/Dir2"
"/Stuff"
"/Stuff/DirK"
"/Stuff/fileX"
...
struct item {
char name[41];
UInt32 parendItemUniqueID;
};
In above example, item "DirK" will store the uniqueID of item "Stuff".
I use reference to parent instead of child. But it should be similiar.
The database has to be sorted to have a better performance. The sorting is a
big pain.
Max
--- Jeremy Neal Kelly <[EMAIL PROTECTED]> wrote:
> Well, I don't really understand what you mean by "first database can have
> many records or each record in the database points a linked list of their
> sub"; however, I think the answer is pretty simple.
>
> Assuming each list is displaying a different type of data, store that data
> in a separate database, with each 'child' database containing a key field
> that links to its parent. Display the parent data in the first list as
> usual; when a record is selected, find and display the child records from
> the second database (if that database is sorted on your 'key' value, a
> binary search will find these records very quickly). Same deal for the third
> table.
>
> This approach has many advantages: it's simple, it's flexible, it supports
> random access to all your data, and it allows you to read records directly
> from storage rather than having to load them into a linked list somewhere.
>
> Does this make sense?
>
>
> "SU DUY TRINH" <[EMAIL PROTECTED]> wrote in message
> news:72669@palm-dev-forum...
> >
> > Hey,
> > What do you think about the hierachy model for
> > some palm apps (on palm
> > hand-held)?For examples:I have a database with many
> > records,all the records
> > are showed in list and then I click on a item of the
> > list,It shows for me
> > about some "subrecords" of the clicked record and then
> > each "subrecords"
> > has many "subrecords" and then so on.So I must use a
> > data structure in tree
> > model like this:
> >
> > struct Record
> > {
> > char contents[NAME_LENGTH+1];
> > Boolean haveSub;//Have sun or not
> > Record *refRec;//refer to list of subrecords of a
> > record
> > };
> > typedef Record *RecordPtr;??????
> > My problems is the following:How do the subrecords
> > of a record save?
> > For examples:I have a database with five records,each
> > record has struct as
> > above,each record has a list of some subrecords(linked
> > list).How do the
> > subrecords of the record save?In other database,if we
> > use the case,I think
> > that:It isn't good because first database can have
> > many records or each
> > record in the database points a linked list of their
> > sub.How do data
> > structure organize for the case?
> > Thanks in advance,
> > Trinh.
=====
-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-
Got Palm?
Get ExBox at http://www.weirdwww.com/ExBox to beam anything!
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/