jagdish eashwar ha scritto:

Hi,
The first Catalyst application of mine deals with the leave records of employees. The second one deals with the hardware that they have been given. Both these applications require details about the employees like their name and employee_no. So I put the employee details in one database called 'common', and the leave particulars in another database called 'leave' , and the hardware details in a third database called 'hardware'.

I was able to put in the foreign key constraints at the time of table creation. And these are working. I cannot, for example, insert an emloyee_no in either the 'leave' or the 'hardware' database if it is not existing in the 'common' database.

So when I was able to do what I had in mind at the database level, I thought it would be possible to do the same with Catalyst and DBIx::Class also. I still haven't lost hope. It would be painful and inelegant to have to replicate the employee details for each of the web applications in the respective databases.

I think you are using the word 'database' to refer to both the DBIC schema and the mysql database, which is confusing.

Since the two dsn in the previous post were the same, I assume your setup is as follows:

- all the data in a mysql database

- multiple Cat apps, each one with its own DBIC schema, all pointing to the sama mysql database, but dealing with a subset of tables

If this is the case, then the fact that the fk constraints at the database level work is to be expected (if you use InnoDB for example).
DBIC, on the other hand, thinks you have multiple databases.


jagdish
On Thu, Jul 3, 2008 at 6:10 PM, Marcello Romani <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Oleg Pronin ha scritto:

        How do you imagine yourself a request with join beetween 2
        tables in different databases?
        This is the reason you can't make relationships between
        different schemas.


    If it's not a typo, the two schemas connect to the same database on
    the mysql side...

    Anyway, I think DBIC sees them as two different databases, even if
    their connections strings are the same...


        2008/7/3 jagdish eashwar <[EMAIL PROTECTED]
        <mailto:[EMAIL PROTECTED]>
        <mailto:[EMAIL PROTECTED]
        <mailto:[EMAIL PROTECTED]>>>:


           I am working on two Catalyst applications and had earlier set up
           separate Mysql databases for each of them. Since some of the
        tables
           that these two applications use, are the same, I put the common
           tables in a third database and created two models in each of the
Catalyst applications. I am, however, unable to set up relationships between tables in the common and specific databases.

           I used myapp_create.pl to create the two models:

           perl script/hardware_create.pl model MyhardwareDB DBIC::Schema
           Myhardware::Schema::MyhardwareDB create=static dbi:mysql:hardware
           'jag' 'passwd' '{ AutoCommit => 1 }'

           perl script/hardware_create.pl model CommonDB DBIC::Schema
           Myhardware::Schema::CommonDB create=static dbi:mysql:hardware
        'jag'
           'passwd' '{ AutoCommit => 1 }'

           and then put in the relationships between the employee and
        hardware
           tables as under:

           # in Emp.pm
           #employee has many hardware
           __PACKAGE__->has_many(emp_hm_hw =>
           'Myhardware::Schema::MyhardwareDB::Hardware', 'hw_emp_id');

           # in Hardware.pm
           #hardware belongs to employee
           __PACKAGE__->belongs_to(hw_bt_emp_id =>
           'Myhardware::Schema::CommonDB::Emp','hw_emp_id');

           When I use these accessors in the tt2 templates, i get an
        undef error.

           undef error -
        DBIx::Class::Relationship::Accessor::__ANON__(): Can't
           find source for Myhardware::Schema::MyhardwareDB::Hardware at
/home/jag/catalyst_trials/Myhardware/root/src/usr_fragment.tt2
        line 8

           What am I doing wrong?

           Jagdish

           _______________________________________________
           List: Catalyst@lists.scsys.co.uk
        <mailto:Catalyst@lists.scsys.co.uk>
        <mailto:Catalyst@lists.scsys.co.uk
        <mailto:Catalyst@lists.scsys.co.uk>>

           Listinfo:
        http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
           Searchable archive:
           http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
           Dev site: http://dev.catalyst.perl.org/



        ------------------------------------------------------------------------


        _______________________________________________
        List: Catalyst@lists.scsys.co.uk <mailto:Catalyst@lists.scsys.co.uk>
        Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
        Searchable archive:
        http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
        Dev site: http://dev.catalyst.perl.org/



-- Marcello Romani
    Responsabile IT
    Ottotecnica s.r.l.
    http://www.ottotecnica.com


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk <mailto:Catalyst@lists.scsys.co.uk>
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/



------------------------------------------------------------------------

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


--
Marcello Romani
Responsabile IT
Ottotecnica s.r.l.
http://www.ottotecnica.com

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to