zooey has asked for the wisdom of the Perl Monks concerning the following question:
Hi all, i want to create simple dictionary application, and have three tables, but I don't know how to set up many to many relationship between them i tried many combinations. Here is how i did it: englishword table: (eng_id, englishword) skwordmeanings table: (sk_id, skword) en_to_sk table: (eng_id,sk_id)
###################################################################### +########## # Package MyDictionary::DBI # # Represents object oriented form of my Database package MyDictionary::DBI; use base "Class::DBI::SQLite"; MyDictionary::DBI->set_db('Main', "dbi:SQLite:dbname=Dictionary.db"); ###################################################################### +########## # Package MyDictionary::Engword # # Represent englishword table package MyDictionary::Engword; use base "MyDictionary::DBI"; MyDictionary::Engword->set_up_table("englishword"); MyDictionary::Engword->has_many('translations',['MyDictionary::En_To_S +k' => 'skword'], 'engword'); ###################################################################### +########## # Package MyDictionary::Skword # # Represent skwordmeaning table package MyDictionary::Skword; use base "MyDictionary::DBI"; MyDictionary::Skword->set_up_table("skwordmeaning"); MyDictionary::Skword->has_many('translations',['MyDictionary::En_To_Sk +' => 'engword'], 'skword'); ###################################################################### +########## # Package MyDictionary::En_To_Sk # # Represents en_to_sk table package MyDictionary::En_To_Sk; use base "MyDictionary::DBI"; MyDictionary::En_To_Sk->set_up_table('en_to_sk'); MyDictionary::En_To_Sk->has_a('eng_id' => "MyDictionary::Engword"); MyDictionary::En_To_Sk->has_a('sk_id' => "MyDictionary::Skword"); ###################################################################### +##########
Thanks a lot
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Class DBI many to many
by Khen1950fx (Canon) on Jun 18, 2011 at 17:26 UTC | |
|
Re: Class DBI many to many
by martell (Hermit) on Jun 18, 2011 at 17:38 UTC | |
by zooey (Initiate) on Jun 19, 2011 at 22:15 UTC | |
|
Re: Class DBI many to many
by moritz (Cardinal) on Jun 18, 2011 at 12:52 UTC |