Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I haven't used DBIx:Class. But it appears that you have a clear set of Towns and a clear set of Residents. This sounds to me like a "has a" relationship, not inheritance ("is a"). A town has a resident, a resident can only belong to one town. A resident is not a town, ie resident is not a sub-class of town. The White House and airplanes both have wings, but they are not sub-classes of Wing.

I'm not a relational DB guy by any means, but the each resident in the resident table would have a "pointer" to the town that this resident belongs to - there are various DB words to describe this, but that is what it is.

I got lost with this part: tables of the Resident kind (Resident_00, _01, etc), to accommodate a few huge towns. There will be just 2 tables as you described. One that describes all the towns. One that describes all the residents. Each resident has a pointer to a town at a minimum. It is also possible for performance reasons to have the DB update a list of pointers to residents for each town.

The DB can generate tables like "give me all residents in town X". It is also possible to "flatten the DB", by putting all the data into a single table. I mean like the Town table could have stuff in it like Latitude, Longitude, #of restaurants, etc. The resident table just has a pointer to that info. You can generate a table with all the info. That is sometimes done for read performance reasons. But say if the #of restaurants changes, I've got a problem as lots of fields have to be updated.

I guess in short, a Class representation may not be what you want? A few huge towns would normally mean to me that the resident table has a lot of duplicate pointers to those huge towns. roboticus knows a lot about such situations and I will defer as to partioning, etc.

Update: I am working on an SQL project now and I recommend:
Learning SQL by Alan Beaulieu
the concepts map very directly into the Perl DBI.


In reply to Re: DBIx::Class with two kinds of otherwise identical table types by Marshall
in thread DBIx::Class with two kinds of otherwise identical table types by dwm042

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 making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-24 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found