Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: [Halito] Difficulty with M->M relationship, intersection table

Quote Reply
Re: [Halito] Difficulty with M->M relationship, intersection table In reply to
Okay, I don't have to learn the M->M relationship right now. It turns out my DB doesn't need that kind of relationship between tables anywhere.

However, I do need to figure out how to auto-insert a record in a second table when I write a record to the first one.

I want all records in table2 to correlate to corresponding records in table1 (1:1 relationship). As table2 has more than 300 fields, I'm assuming it's a good idea to put them in a separate table since they won't be accessed as frequently by users as the data in table1.

I currently have a global, add_table2, that I cobbled together from an example in the help documentation. It doesn't produce an error, but it doesn't add a record to the second table, either. It looks like this:

sub {
my $sql = shift;
my $rel = $DB->table (qw/table1 table2/);
$rel->insert ( { table2_ID => 'table1_ID' } );
}


I have the ID field in table2 defined as a non-auto-incrementing foreign key pointing to table1_ID. I'm thinking each table should share the same ID number from table1 so I can easily switch back and forth from one table to the other in my HTML.

Can anyone help? Thanks.
Subject Author Views Date
Thread Difficulty with M->M relationship, intersection table Halito 4241 Mar 28, 2002, 6:25 AM
Thread Re: [Halito] Difficulty with M->M relationship, intersection table
Halito 4114 Apr 3, 2002, 3:17 AM
Thread Re: [Halito] Difficulty with M->M relationship, intersection table
Halito 4097 Apr 19, 2002, 6:47 AM
Post Re: [Halito] Difficulty with M->M relationship, intersection table
Halito 4055 Apr 24, 2002, 7:53 AM