Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Help with foreign key relations

Quote Reply
Help with foreign key relations
Hi, I know you have used foreign keys Ivan, and I am wondering if you or anyone else could straighten its use out for me.

This is a ficticious example (the actual fields are not real for this example), but lets say I wanted this new database which is created during plug-in install, to always mirror my users file (i.e. same number of records, idential ID's for each user). Assuming when you add or delete a record from the users table, this table would automatically be affect also. Is this syntax correct? Would someone mind confirming that the action is oneway i.e. only changes to the master table (Users in this case) will affect the other table, and not the other way around???Crazy

Code:
$c2->cols (
ID => { pos => 1, type => 'INT', not_null => 1, regex => '^\d+$' },
Announcements => { pos => 2, type => 'CHAR', size => '255', not_null => 0, default=> 'None.' },
blah blah
Username => { pos => 7, blah blah blah }
);
$c2->pk('ID'); <<Do I still need to specify the primary key when using an fk?
$c2->ai('ID');
$c2->fk ( {
'Users' =>
{ ID => ID,
...
LinkOwner => LinksOwner
}
}
);

if (! $c2->create()) {
$GT::SQL::errcode ||= '';
$GT::SQL::errcode eq blah blah blah
$c2->set_defaults();
$c2->save_schema();
};




I apologise for the untidy formatting, cut and paste is behaving strangelyBlush


http://www.iuni.com/...tware/web/index.html
Links Plugins

Last edited by:

Ian: Jun 29, 2002, 1:32 PM
Subject Author Views Date
Thread Help with foreign key relations Ian 3915 Jun 29, 2002, 1:19 PM
Thread Re: [Ian] Help with foreign key relations
pugdog 3825 Jun 29, 2002, 9:25 PM
Post Re: [pugdog] Help with foreign key relations
Ian 3806 Jun 29, 2002, 9:56 PM
Thread Re: [Ian] Help with foreign key relations
Alex 3827 Jun 30, 2002, 10:50 PM
Post Re: [Alex] Help with foreign key relations
Ian 3792 Jun 30, 2002, 11:30 PM
Thread Re: [Alex] Help with foreign key relations
pugdog 3795 Jul 1, 2002, 11:38 PM
Post Re: [pugdog] Help with foreign key relations
Ian 3780 Jul 1, 2002, 11:51 PM