Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I think the question hinges on when the linkage information first becomes available: is it instrinsically known at the point when an object instance is created, or might it get introduced at some later stage as an update to an existing instance?

If it makes sense that instances of each object type are able to exist independently, without necessarily being linked to one of the other object types, then it would make sense for link creation to be a separate process, which takes a taxon instance and a node or sequence instance, and updates each one by adding a reference to the other. (In the taxon, a reference to a node or sequence would be pushed onto an array of nodes or sequences; in a node or sequence, there can be only one reference to a given taxon.)

OTOH, if every node and/or every sequence being created is inherently related to a specific taxon, then it would make sense that the "new()" method for node and sequence objects would take a required reference to a taxon instance, check to make sure this reference is defined, create the new node or sequence instance that contains the reference to that taxon, and finally invokes the "add_node" or "add_sequence" method of that taxon, to make the relation bidirectional.

(At least one of the object types needs to be able to exist independently, without requiring a relation to the other types. It sounds like the taxon object would be that way for sure.)

(update: And I agree with TOD, that it makes more sense if the underlying data storage is a relational database, where foreign key relations can be enforced automatically once you define the tables properly, rather than just being a bunch of perl-internal objects.)


In reply to Re: One to many, many to one relationships by graff
in thread One to many, many to one relationships by rvosa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-26 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found