[Dbix-class] newbie questions on development practices

john edstrom edstrom at teleport.com
Fri Jun 22 19:24:28 GMT 2007


hi,

I'm just getting started and have a couple questions.

1) I began with a simple set of tables & relations (see attached
diagram).  

I created the initial class description from what I read in the
documentation and used SQL::Translator to build SQL files to create the
tables & stuff.

It got everything right except the foreign key linking users.uid to
thing.thid.  It just wouldn't do it no matter what I tried
(belongs_to,might_have,etc) it just wouldn't generate a foreign key
there.

So, I created the tables by hand and DBIx::Class::Schema::Loader grokked
it correctly (as far as I could tell).  So I took the generated DBIx
descriptions, ran them through the translator and the uid->thid foreign
key failed to appear again.  So I'm guessing its a problem with the
translator, or at least the DBIx/Translator interface.

My question is, what's the 'best practice' here for ginning up a new
project?  Craft the tables by hand (or 3rd party tool), infer it with
the schema loader and use the inferred classes to work with?  Or is
there a better way?


2) I created a view for a user-thing (basically a user as a subclass of
thing) with the usual joins and things.  

The schema loader saw it and captured the structure OK but didn't
analyze the view any deeper (PostgreSQL 8.1, btw).  I didn't really
expect it to, so I'm not complaining.

But I can see how defining a complex search with DBIx might get gnarly
as the project progresses and it occurred to me that if DBIx::Class
could analyze views then it could use that as a sort of
DBIx::Class::ResultSet definition, either to create a
DBIx::Class::ResultSet definition file, or maybe employ a pre-existing
view in searches.

Are there any plans for using views in DBIx in the future?




	JE





-- 
john edstrom <edstrom at teleport.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diagramA.png
Type: image/png
Size: 6627 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070622/2833a5a3/diagramA.png


More information about the Dbix-class mailing list