Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

(bbfu) (parents' children) Re(2): Will this break your program?

by bbfu (Curate)
on Apr 28, 2001 at 01:15 UTC ( [id://76270]=note: print w/replies, xml ) Need Help??


in reply to Re: Will this break your program?
in thread threaded display of replies

so said little:

    And btw, there is no need to let anode [sic] know if it has children or not. If there are children THEY WILL KNOW their parent.

Unless, of course, you want to find all the children of a particular node without doing an exhaustive search of the DB. While not strictly necessary, it can make life simpler in some cases. I think this application might qualify as one of those cases (see Masem's reply). :-)

bbfu
Seasons don't fear The Reaper.
Nor do the wind, the sun, and the rain.
We can be like they are.

  • Comment on (bbfu) (parents' children) Re(2): Will this break your program?

Replies are listed 'Best First'.
Re: (bbfu) (parents' children) Re(2): Will this break your program?
by little (Curate) on Apr 28, 2001 at 15:56 UTC
    But that blows up your DB to an expensive amount, when you store the children node id's to a node. Remeber, you will never know how many children a node will have. But a child node always has only one parent.
    Have a nice day
    All decision is left to your taste

      Well, I was figuring you would only store children's node id, and only one deep (ie, immediate children). Unless each node in your application is expected to have an extreme amout of immediate children, I don't see that it would be a problem.

      Let's see... Generously, 4 bytes to store a node id and 100 immediate children on avg. gives only 400 extra bytes per node. That's not a huge amount and most nodes on PM have far less than 100 immediate children. I don't recall any I've seen with greater than 30. That's only 120 extra bytes per node.

      Not sure how many, if any, DB's support variable length data-arrays but you could always use a blob and pack it yourself. A little more work, but not as much as an exhaustive search of the DB for every node with a parent ID of xx.

      Don't get me wrong, I understand your point and I know that it might not be worth it in some cases. I just don't think that most cases (and this one in particular) would be that hurt by the cost and I think the benefit would outway the small cost of extra size. 'Tis, of course, the Implementator's call; and the point is moot in this case unless we feel like submitting a patch to EveryDevl.com. :-)

      Disclaimer: It is quite possible (likely?) that I am mistaken and/or am relying on an invalid assumption. I don't know a great amount about the Everything engine, nor even the general implementation of such systems. Therefore, I provide no warranty for this post, expressed or implied, for fitness of use or merchantability or anything else. I disavow all knowledge of my own actions and assume no responsibility for anything. ;-)

      bbfu
      Seasons don't fear The Reaper.
      Nor do the wind, the sun, and the rain.
      We can be like they are.

        Not sure how many, if any, DB's support variable length data-arrays but you could always use a blob and pack it yourself. A little more work, but not as much as an exhaustive search of the DB for every node with a parent ID of xx.

        The two things I've learned about relational databases are :

        • Don't create artificial data structures within blobs, the DB is better at handling them than you are.
        • If you have a many-to-many relationship (== variable length array in Perl), use another table with the relations in it.
        In this case, this would mean having a relation table, isChild, which would consist of two columns, parentID and childID. If you have a database with triggers, you can maintain the integrity with stored procedures, if not, you can at least handle node deletions gracefully with a small SQL script.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76270]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-06-21 02:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.