[Dbix-class] newbie questions on development practices

John Napiorkowski jjn1056 at yahoo.com
Fri Jun 22 22:55:32 GMT 2007


--- john edstrom <edstrom at teleport.com> wrote:

> 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?

Well, I doubt it's the best way for all things, but I
personally use a modeling tool, like Toad Data
Modeler, that let's me generate DLL for different
target Databases.  I then build the database with the
DLL and using DBIC::Loader to dump generated classes. 
I then end up tweaking the classes a bit to get them
the way I like.

I prefer this method because I like to work in a
visual modeling tool.  However I doubt my method plays
nice with all the cool versioning stuff that was a big
part of the .8 rollout.

--john


> 
> 
> 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>
> > _______________________________________________
> List:
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN:
>
http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
http://www.mail-archive.com/dbix-class@lists.rawmode.org/



      ____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ 



More information about the Dbix-class mailing list