dbTalk Databases Forums  

'contains' self relationship

comp.databases.filemaker comp.databases.filemaker


Discuss 'contains' self relationship in the comp.databases.filemaker forum.



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

Default 'contains' self relationship - 07-24-2005 , 02:47 PM






I need to figure out how to identify records that contain the text of
other records.

example:
I have a table called PHRASES, with a field called PHRASE .
sample records:
recid=1 phrase=bob
recid=2 phrase=bob barker
recid=3 phrase=bob barker game show
recid=4 phrase=bob game

I need to establish a relationship (note: I need a relationship, NOT a
script, a script approach is useless to me) that would identify the
record (any record) whose PHRASE contains the PHRASE in the first
record. so, following the same example:
sample records:
recid=1 parentid=null phrase=bob
recid=2 parentid=1 phrase=bob barker
recid=3 parentid=2 phrase=bob barker game show
recid=4 parentid=1 phrase=bob game

the idea here is to identify a lexical chain that will allow me to on
the fly determine how to short circuit a lengthy process. if for
exampe, record 2 has no results in my theoretical processing, then
neither will 3... if 1 has no results, neither will 2, 3, or 4:

2 -- 3
/
1
\
4

to be really basic, I'm trying to get around filemaker's shortcoming of
now allowing CONTAINS as an operator in the relationship. I got REAL
close by using a < relationship and sorting the right hand side of the
join by PHRASE descending,, but no cigar, the previous phrase doesn't
necessarily contain the phrase in question, it's simply lower
alphabetically.

any ideas folks?

thanks,
b


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

Default Re: 'contains' self relationship - 08-05-2005 , 12:31 PM






In order to relate based on "contains", you need a calc field on both sides
that will give you all the combinations of letters in the phrase.
F'rinstance:

"Hello" becomes:

H
He
Hel
Hell
Hello
e
el
ell
ello
l
ll
llo
l
lo
o

When evaluating a relationship where one or both sides contains a
return-separated list, FM will match on any one of the list values. Thus,
the calcs on either side, where one side has Hello broken out, and the other
has hell broken out, the records will be related.

For pre-FM7, there's a plugin called "Portal Filter" that will do this. In
FM7, you can create a recursive custom function to accomplish this (assuming
you have Developer). For the custom function route, google "FileMaker custom
functions", or start with Brian Dunning's web site, which has a good list of
useful custom functions and (I believe) includes one to do exactly this.

--

Shadenfroh
shadenfroh (AT) yahoo (DOT) com

"grasshopper" <bob (AT) nowhere (DOT) com> wrote

Quote:
I need to figure out how to identify records that contain the text of
other records.

example:
I have a table called PHRASES, with a field called PHRASE .
sample records:
recid=1 phrase=bob
recid=2 phrase=bob barker
recid=3 phrase=bob barker game show
recid=4 phrase=bob game

I need to establish a relationship (note: I need a relationship, NOT a
script, a script approach is useless to me) that would identify the
record (any record) whose PHRASE contains the PHRASE in the first
record. so, following the same example:
sample records:
recid=1 parentid=null phrase=bob
recid=2 parentid=1 phrase=bob barker
recid=3 parentid=2 phrase=bob barker game show
recid=4 parentid=1 phrase=bob game

the idea here is to identify a lexical chain that will allow me to on
the fly determine how to short circuit a lengthy process. if for
exampe, record 2 has no results in my theoretical processing, then
neither will 3... if 1 has no results, neither will 2, 3, or 4:

2 -- 3
/
1
\
4

to be really basic, I'm trying to get around filemaker's shortcoming of
now allowing CONTAINS as an operator in the relationship. I got REAL
close by using a < relationship and sorting the right hand side of the
join by PHRASE descending,, but no cigar, the previous phrase doesn't
necessarily contain the phrase in question, it's simply lower
alphabetically.

any ideas folks?

thanks,
b




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.