On 12 Mar 2008, at 10:28, Remco Zwaan wrote:
>
> Hi,
>
> Newbie question (i hope)
>
> 2 tables (no rails specs)
>
> CREATE TABLE `werelddelen` (
>  `id` smallint(2) unsigned NOT NULL auto_increment,
>  `naam` varchar(50) default NULL,
>  `naam_en` varchar(50) default NULL,
>  `zoeknaam` varchar(50) default NULL,
>  PRIMARY KEY  (`id`),
>  KEY `zoeknaam` (`zoeknaam`)
> )
>
> CREATE TABLE `landen` (
>  `landcode` char(2) NOT NULL default '''',
>  `naam` varchar(50) NOT NULL,
>  `naam_en` varchar(50) NOT NULL,
>  `alt_naam` varchar(200) NOT NULL,
>  `landafk` char(3) default NULL,
>  `land_zoeknaam` varchar(100) NOT NULL default '''',
>  `werelddeel_id` tinyint(2) unsigned default NULL COMMENT
> ''wereldelen.id'',
>  PRIMARY KEY  (`landcode`),
>  KEY `land_zoeknaam` (`land_zoeknaam`),
>  KEY `werelddeel_id` (`werelddeel_id`)
> )
>
> How can realize a one to many relationship between this tables.(cannot
> change column-names, because this is our central company database)
>
> 1)Werelddelen(continents) can have more than 1 land(countries)
> 2)Land only can have 1 werelddeel(continent)
You want a belongs_to and a has_many. You can use the foreign_key  
option to tell it to use the werelddeel_id column.
Fred>
>
>
> Grtz..remco
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---