Normal Topic Many to Many structure? (Read 1053 times)
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Many to Many structure?
Jun 14th, 2007 at 3:51am
Print Post Print Post  
I Am working to set up database and it looks like a classic many-to-many relationship.  but don't know how to set this up in Sesame higherarch structure.  Expect to have a Top Form for Cusotmers database with sub form showing line items for services/products purchased.  But also want to have a Top Form for Parts with a subform showing all Customer purchases of that service.  It sounds like three databases but is really only two databases.  How do I set this up using the naturale order that Sesame works with?
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Many to Many structure?
Reply #1 - Jun 14th, 2007 at 4:41am
Print Post Print Post  
obfusc88,

Check out the Sesame Seasons sample database. It is a terrific example of customer, invoice and products. It was written by Ray the reaper. It is a great database to learn from.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
nelsona
Member
*
Offline


No personal text

Posts: 10
Joined: Jan 10th, 2006
Re: Many to Many structure?
Reply #2 - Jun 22nd, 2007 at 5:13pm
Print Post Print Post  
to do something like this you'll need to use a junction table

you'll have to excuse me as this is in SQL I haven't used sesame in a while:

http://en.wikipedia.org/wiki/Junction_table
  
Back to top
 
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: Many to Many structure?
Reply #3 - Jul 3rd, 2007 at 2:22am
Print Post Print Post  
thank you for your suggestions but i still do not understand.  i looked at the Sesame Seasons but did not see anything like a many to many structure.  and I have no idea what the link to SQL does to help me.  Does this mean I need to make the many to many structure in another database and need to use SQL somehow to do this?  Database A is Employee.  Database B is Safety Class.  It is like I need database B to be a child of database A, and I also need database A to be a child of database B.  Each Employee will have many Safety Classes, and each Safety Course will have multiple employees as students.  So I want a subform of all Safety Courses on the Employee record.  And I want a subform showing all Employees who attended on each Safety Course recrods.
  
Back to top
 
IP Logged
 
nelsona
Member
*
Offline


No personal text

Posts: 10
Joined: Jan 10th, 2006
Re: Many to Many structure?
Reply #4 - Jul 3rd, 2007 at 4:19pm
Print Post Print Post  
Using junction tables shouldn't be a SQL specific task. Again I haven't touched sesame in a long time,
but you would need three tables: Employee,  Safety Class, and  the junction table.



+---------+                +----------------+               +-------------------+
|Employee|                | JunctionTable  |                |                        |
|             |                 | emp | safety  |                | Safety Class      |
+---------+                +----------------+               +-------------------+
|1           |                 |   1       |  A     |                | A | ISO9001      |
+---------+                +----------------+               +-------------------+
|2           |                 |    2      |    A  |                | B | Chem spills   |
+---------+                +----------------+               +-------------------+
|3           |                 |     2     |    C  |                | C |pointy objects |
+---------+                +----------------+               +-------------------+
|4           |                 |    3     |     D  |                | D | germs         |
+---------+                +----------------+               +-------------------+
|5           |                 |     2     |    B  |
+---------+                +----------------+

_________________________________________________________________

Note that on both Employee and Safety Class both have unique IDs (Primary Keys) 1,2,3,4,5 and A,B,C,D respectively.
Now on the JunctionTable you see that that neither employee or safety class entries are unique, they are what is called foreign keys,
that is  the "emp" field in the junction table is a foreign key for  the employee table and  safety field from the junction table is a foreign key for the
safety class table.

in essence you'll use a third table to "join" the two tables together.

Hopefully this explains it a little better, as you don't need SQL  to do this, It was just the example it used, Sesame should do it just fine.
  
Back to top
 
IP Logged
 
obfusc88
Full Member
***
Offline


No personal text

Posts: 194
Joined: Dec 17th, 2005
Re: Many to Many structure?
Reply #5 - Jul 9th, 2007 at 5:39pm
Print Post Print Post  
Thank you to Mr. nelsona.  I just got back from vacation and saw your reply.  I did not try that yet, but that looks like FoxPro relational structures that should work.  I will the the inner join database to record the classes for each employee and sue the two outer datbases as subofrms to the inner form.  So I should be able to use natural links, makiing two different subforms from the inner form that will be the parent.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Many to Many structure?
Reply #6 - Jul 9th, 2007 at 7:37pm
Print Post Print Post  
obfusc88 wrote on Jul 9th, 2007 at 5:39pm:
Thank you to Mr. nelsona.  I just got back from vacation and saw your reply.  I did not try that yet, but that looks like FoxPro relational structures that should work.  I will the the inner join database to record the classes for each employee and sue the two outer datbases as subofrms to the inner form.  So I should be able to use natural links, makiing two different subforms from the inner form that will be the parent.


Keep in mind that a subdatabase can have only one natural parent. Depending on what you do, one or both of your links may want to be relational.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged