[Dbix-class] best way to share schema elements?

Seth Daniel dbix-class at sethdaniel.org
Tue Nov 12 00:55:12 GMT 2013


If I want to share schema definitions, across tables, using DBIx::Class
what is the best way to do this?

I've looked at DBIx::Class::DynamicSubclass,
DBIx::Class::Helper::Row::SubClass, and the examples in
DBIx::Class::Manual::Cookbook (in the section 'Static sub-classing
DBIx::Class result classes').  All of these deal with related Result
classes (which is what I want) but also seem to all assume that the
subclassing or hierarchy is modeled in a single table (or it seems that way
to me).

Let's say I have two things I want to model (A and B).  They are similar,
but not the same.  Despite not being the same many cases I can treat them
as being the same.  Using any of the above modules it seems I would have to
do this with a single table.  Which also means that if A has relationships
that B doesn't have I would not be able to have the relationships defined
in the schema (I would be able to have them defined in the result class as
I understand it).   Is this correct?  If I'm wrong what is the best way to
model having many shared columns/relationships over 2 or more tables
without repeating myself?  Is there a way in DBIx::Class to model where an
A and B table "inherit" from a base table?  Is there a good way to do this
in DBIx::Class?  Is this a good way to do this in DBix::Class?

A not entirely unrelated question: is there a preferred way to share column
definitions among non-related tables?  So if I want a username in one table
and want the same definition for username in a different table is there a
preferred way to share this definition among the result classes?  I can
think of several ways to do it but wondering if there is a best practice
wrt DBIx::Class.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20131111/ba7=
03c79/attachment.htm


More information about the DBIx-Class mailing list