home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!stanford.edu!rock!concert!glv!usenet
- From: bob@bobsled.glv.com (Bob Lunney)
- Subject: Re: Table Design Hint needed
- Message-ID: <1992Nov19.135313.2491@glv.uucp>
- Sender: usenet@glv.uucp
- Nntp-Posting-Host: bobsled
- Organization: Encompass
- References: <BxxqJ4.Cs0@ccu.umanitoba.ca>
- Distribution: usa
- Date: Thu, 19 Nov 1992 13:53:13 GMT
- Lines: 41
-
- In article <BxxqJ4.Cs0@ccu.umanitoba.ca> ummalik@ccu.umanitoba.ca (Ijaz Rashid
- Malik) writes:
- >
- > Hello,
- > I have to design two tables and I need some help to minimize the duplication
- > etc.
- >
- > One table is "businesses" and key fields is business ID.
- > Other is "directors" and key is dir. ID.
- > A business can have more than one directors and a director can control more
- > than one business.
- > Both table have to be linked so that all directors for a given business or
- > all businesses under given director could be listed.
- > My thinking either calls for mulitple Dir. ID. columns in business table
- > (dir1. ID, dir2. ID...) but its not practicle as # of directors varies. OR
- > same director could be listed in directors table under different ID's and
- > there is a column (field) called Business ID which points to the business
- > controlled by this person but problem with this is that same record is listed
- > multiple times ==> redundancy!!!
- > Could someone please help me out here with some hints...
- >
- > Thanks very much!
- > Malik
- > ummalik@ccu.umanitoba.ca
-
- Ah, the not-so-dreaded many-to-many relationship. Try inserting a two column
- table between "businesses" and "directors" (call it "business_directors" for
- sake of argument"). The "business_directors" table then has two columns,
- business_ID and director_ID. No mix and match businesses to directors in the
- "business_directors" table however you would like. The foreign key
- relationship between "businesses" and "business_directors" is via business_ID,
- of course, and the foreign key relationship between "directors" and
- "business_directors" is via director_ID. Note that the primary key for
- "business_directors" is both business_ID and director_ID (you need to know both
- values to select one business and match it to one director). Good Luck!
-
- Bob Lunney bob@bobsled.glv.com NeXTmail preferred!
- Encompass 919-460-3274
-
- Disclaimer: My company doesn't allow me to have opinions - I might
- inadvertantly speak for myself or someone else.
-