Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

RE: Re: Storing Complex Structures in a database

by jreades (Friar)
on Oct 02, 2000 at 20:05 UTC ( [id://34920]=note: print w/replies, xml ) Need Help??


in reply to Re: Storing Complex Structures in a database
in thread Storing Complex Structures in a database

VARCHAR would probably not be a good idea here as the data is likely to exceed 255 characters (MySQL restriction) pretty quickly.

If the post-er wants to serialize, I'd imagine that blob or text would be a more flexible solution and without the 255 character restriction.

Personally, I'd go with a single table approach (assuming that each node has only a single parent) using a parent node id field...

nodes
node_id (UNIQUE INT)
parent_node_id (INT)
data (whatever is relevant)

That's just an off-the-cuff response, but as your nodes and subnodes theoretically contain the same information I wouldn't go sticking them in different tables. This way works by simply adding a parent_node_id column that would allow you look either up or down the node tree any arbitrary amount. It's not necessarily the fastest way (because of the multiple selects to move up or down the tree, so as the nodes reach 'n' levels they take, what is it, O(n) time) but it represents a relatively consistent interface that won't throw you into problems with your database.

A question of tradeoffs I suppose.

  • Comment on RE: Re: Storing Complex Structures in a database

Replies are listed 'Best First'.
RE: RE: Re: Storing Complex Structures in a database
by lhoward (Vicar) on Oct 02, 2000 at 20:53 UTC
    I should have been clearer. When I said VARCHAR what I meant was "some sort of character storage that is of variable length" not necessarily the VARCHAR type. The exact name of the apropriate type will vary based on your database and your storage needs.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-24 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found