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