digger has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I've been asked to take on a project to import a number of xml files into a database. The data model is not great and I think it is a problem for DBIx::Class.

Let's say we have 3 tables, A, B and C. B and C reference A and C references B. When DBIx::Class generates the sql to insert a record for this design it will leave off one of the foreign keys. Most often, it is the foreign key that is accessible through the relationship instead of directly.

I know the db layout isn't great, but it is what I was given and I don't have the luxury of changing it at this point. Is this an issue with DBIC? Is it too smart to work with ugly db designs?

I appreciation any insight.

Replies are listed 'Best First'.
Re: Trouble with DBIx::Class
by Your Mother (Archbishop) on Dec 01, 2015 at 20:52 UTC

    It's not that it is smart, it's that it tries to be proper. Bad schemata are a clash for that. Many to many is not a true relationship though and that might be what you're running into(?). You can define it manually though and get quite a bit of DWIM behavior.

      This is a situation where management allowed the customer to define the schema instead of the dba. The issue I presented turned out to be one of many issues. It was only 13 tables, so I wrote the queries and built the relationships by hand. It is an import script that runs once a year and not worth spending hours trying to make DBIx::Class work.

      Thanks for your input!