Results 1 to 2 of 2

Thread: Example for many-to-many relationship

  1. #1
    tina2007 is offline Sugar Community Member
    Join Date
    Apr 2007
    Posts
    26

    Default Example for many-to-many relationship

    I know there are one-to-many and many-to-many relationship. I find a lot of one-to-many relationship, but could anyone give me an example of many-to-many relationship?

    I have built an new module named groups and I want to assign the contacts to groups, how can i do it? if it's possible that one contact could belong to more than more groups?

    Need your help!
    Tina.

  2. #2
    roblaus's Avatar
    roblaus is offline Sugar Community Member
    Join Date
    Dec 2006
    Location
    Vienna / Austria
    Posts
    2,850

    Default Re: Example for many-to-many relationship

    Hi,

    A many to many relationship cannot be expressed directly. You always have to go through relationship tables. You'll find many of them in Sugar but few of them are actually used in the program logic. As a working example: opportunities_contacts with the main fields: id (the identifier of the record itself), contact_id, opportunity_id.

    Whenever you add a contact to an opportunity a new record is inserted into this table. If you later on open the subpanel contacts under an opportunity a SQL statement is fired that in principle says "select (fields) from contacts where id in (select contact_id from opportunities_contacts where opportunity_id = (id of the current opportunity))"

    There's a lot more to say but I hope that will do as a start...

    rgds
    __________________________
    Robert Laussegger
    http://www.iscongroup.net

    Bei Fragen: support@iscon.at
    Die deutschen Sprachdateien für SugarCRM und das deutsche Handbuch gibt es hier: http://goo.gl/kPsAz
    Ab sofort auch mit 6.4.2

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. problemi step 6 di SugarSuite-Full-4.0.1h
    By lucia in forum Italiano
    Replies: 0
    Last Post: 2006-12-27, 08:50 AM
  2. Asterisk Patch 1.1.0 Crash on logon
    By skyracer in forum Help
    Replies: 6
    Last Post: 2006-07-08, 06:30 AM
  3. Replies: 7
    Last Post: 2006-06-06, 07:56 PM
  4. 4.0.1 Installation Problem
    By clawton in forum Help
    Replies: 14
    Last Post: 2006-02-13, 04:17 PM
  5. Query erro after 4.0 upgrade
    By ldebernardini in forum Help
    Replies: 20
    Last Post: 2006-01-13, 05:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •