home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / database / sybase / 358 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.4 KB  |  55 lines

  1. Newsgroups: comp.databases.sybase
  2. Path: sparky!uunet!stanford.edu!rock!concert!glv!usenet
  3. From: bob@bobsled.glv.com  (Bob Lunney)
  4. Subject: Re: Table Design Hint needed
  5. Message-ID: <1992Nov19.135313.2491@glv.uucp>
  6. Sender: usenet@glv.uucp
  7. Nntp-Posting-Host: bobsled
  8. Organization: Encompass
  9. References: <BxxqJ4.Cs0@ccu.umanitoba.ca>
  10. Distribution: usa
  11. Date: Thu, 19 Nov 1992 13:53:13 GMT
  12. Lines: 41
  13.  
  14. In article <BxxqJ4.Cs0@ccu.umanitoba.ca> ummalik@ccu.umanitoba.ca (Ijaz Rashid  
  15. Malik) writes:
  16. > Hello,
  17. > I have to design two tables and I need some help to minimize the duplication
  18. > etc.
  19. > One table is "businesses" and key fields is business ID.
  20. > Other is "directors" and key is dir. ID.
  21. > A business can have more than one directors and a director can control more
  22. > than one business.
  23. > Both table have to be linked so that all directors for a given business or
  24. > all businesses under given director could be listed.
  25. > My thinking either calls for mulitple Dir. ID. columns in business table
  26. > (dir1. ID, dir2. ID...) but its not practicle as # of directors varies. OR
  27. > same director could be listed in directors table under different ID's and 
  28. > there is a column (field) called Business ID which points to the business
  29. > controlled by this person but problem with this is that same record is listed
  30. > multiple times ==> redundancy!!!
  31. > Could someone please help me out here with some hints...
  32. > Thanks very much!
  33. > Malik
  34. > ummalik@ccu.umanitoba.ca
  35.  
  36. Ah, the not-so-dreaded many-to-many relationship.  Try inserting a two column  
  37. table between "businesses" and "directors" (call it "business_directors" for  
  38. sake of argument").  The "business_directors" table then has two columns,  
  39. business_ID and director_ID.  No mix and match businesses to directors in the  
  40. "business_directors" table however you would like.  The foreign key  
  41. relationship between "businesses" and "business_directors" is via business_ID,  
  42. of course, and the foreign key relationship between "directors" and  
  43. "business_directors" is via director_ID.  Note that the primary key for  
  44. "business_directors" is both business_ID and director_ID (you need to know both  
  45. values to select one business and match it to one director).  Good Luck!
  46.  
  47. Bob Lunney    bob@bobsled.glv.com    NeXTmail preferred!
  48. Encompass    919-460-3274
  49.  
  50. Disclaimer:  My company doesn't allow me to have opinions - I might      
  51.          inadvertantly speak for myself or someone else.
  52.