dbTalk Databases Forums  

question re one to many reltionships

comp.databases.filemaker comp.databases.filemaker


Discuss question re one to many reltionships in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Luke Siemaszko
 
Posts: n/a

Default question re one to many reltionships - 09-13-2005 , 08:12 AM






FMP7

As far as I can see a one to many relationship will always only return
the first record.

is that correct?

i would really like to be able to step through all the related records

is this possible or will i have to work out aanother strategy

thanks



Reply With Quote
  #2  
Old   
Grip
 
Posts: n/a

Default Re: question re one to many reltionships - 09-13-2005 , 01:13 PM






A relationship doesn't return anything...it's just part of the
structure of your database. A portal may help you, or a looping
script. If you give a specific scenario we might be able to help you
more.

-G


Reply With Quote
  #3  
Old   
Steven Bitaxi
 
Posts: n/a

Default Re: question re one to many reltionships - 09-13-2005 , 02:30 PM



Use a portal in your primary file. This will allow you to view and
scroll through all the records related to the "parent" record.


Reply With Quote
  #4  
Old   
Luke Siemaszko
 
Posts: n/a

Default Re: question re one to many reltionships - 09-13-2005 , 03:00 PM





Grip wrote:
Quote:
A relationship doesn't return anything...it's just part of the
structure of your database. A portal may help you, or a looping
script. If you give a specific scenario we might be able to help you
more.


OK, "return" is the wrong word, sloppy terminology.

I have a table that contains a list of users lets call it table A.
There is another table that contains various information per user, lets
call it table B
There are multiple records per user in table B, reflecting different
operating environments

Table A and table B are related by user name.

What I want to do is run a script that finds a user in table A, then
through the relationship lets me step through all the matching records
in table B.

But I don't seem to be able to work out the mechanism for getting the
next related record. Whatever I do always seems to give the first
related record only.

I hope that's clear.

Thanks for any help.



Reply With Quote
  #5  
Old   
Helpful Harry
 
Posts: n/a

Default Re: question re one to many reltionships - 09-13-2005 , 04:07 PM



In article <OLGdnatI1YLYTbveRVnyjg (AT) eclipse (DOT) net.uk>, Luke Siemaszko
<no.spam.for.me (AT) please (DOT) com> wrote:

Quote:
FMP7

As far as I can see a one to many relationship will always only return
the first record.

is that correct?

i would really like to be able to step through all the related records

is this possible or will i have to work out aanother strategy

thanks
If you have a relationship defined as:

File A::Link Field ---> File B:: Link Field

then whenever you use a function around that relationship it will by
default use only the first related record.
eg. For
Set Field (TempField, Relation::Other Field)

TempField will be give the value of Other Field from the
first related record.


BUT, there are two exceptions to this ...

A. When using aggregate functions, the result will be
aggregated from ALL the related records.
eg. For
Set Field (TempField, Sum(Relation::Other Field))

TempField will be set to the total sum of Other Field
for ALL the related records.

B. When using a portal and the user / script has activated a
particular portal row, then the values from THAT row's
related record is used.


That second one means you can use a script to loop through a portal
collating values from all the related records.
eg. When on a layout with a portal using the Relationship, you can use
a script something like this:

Go To Portal Row [First]
Loop
Set Field (Temp Field, Temp Field & "¶"
& Relation::Other Field)
Got To Portal Row [Next, Exit after last]
End Loop

This will loop through all the related records and append
each portal row's value of Other Field to the end of Temp
Field (separated by the ¶ / carriage return character).



Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #6  
Old   
FP
 
Posts: n/a

Default Re: question re one to many reltionships - 09-13-2005 , 04:53 PM



If your wanting to script something and your script needs to operate on
the records in table B, then simply use the script step "go to related
records" with the option "Show only related records". You'll end up at
a layout displaying records from table B but only the ones that are
related to the table A record that you were at.
You can then Loop through those records and once done, your script can
"Go to Layout Original"


Reply With Quote
  #7  
Old   
Chris Brown
 
Posts: n/a

Default Re: question re one to many reltionships - 09-14-2005 , 07:10 AM



Luke Siemaszko wrote:
Quote:
FMP7

As far as I can see a one to many relationship will always only return
the first record.

is that correct?

i would really like to be able to step through all the related records

is this possible or will i have to work out aanother strategy

thanks



Hi Luke,

the rel will 'return' the first record value it finds depending on the
sort, in a single related (eg portal-less) field or calc. It really
shows all the related values in a portal. There is a subtle distinction.

Chris



Reply With Quote
  #8  
Old   
Luke Siemaszko
 
Posts: n/a

Default Re: question re one to many reltionships - 09-14-2005 , 02:31 PM





FP wrote:
Quote:
If your wanting to script something and your script needs to operate on
the records in table B, then simply use the script step "go to related
records" with the option "Show only related records". You'll end up at
a layout displaying records from table B but only the ones that are
related to the table A record that you were at.
You can then Loop through those records and once done, your script can
"Go to Layout Original"

Aaah, but I need to do a calculation on a field from table A and a field
from table B in the same line



Reply With Quote
  #9  
Old   
FP
 
Posts: n/a

Default Re: question re one to many reltionships - 09-14-2005 , 06:52 PM



Quote:
Aaah, but I need to do a calculation on a field from table A and a field
from table B in the same line
If there are multiple records in table B for 1 record in table A then
you can only pull of this calculation from a record in table B.



Reply With Quote
  #10  
Old   
42
 
Posts: n/a

Default Re: question re one to many reltionships - 09-15-2005 , 06:31 AM



In article <OLGdnatI1YLYTbveRVnyjg (AT) eclipse (DOT) net.uk>,
no.spam.for.me (AT) please (DOT) com says...
Quote:
FMP7

As far as I can see a one to many relationship will always only return
the first record.

is that correct?

i would really like to be able to step through all the related records

is this possible or will i have to work out aanother strategy

look at the docs for portals


-dave


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.