Jump to content
Salesforce and other SMB Solutions are coming soon. ×

I am a newbie and need help S-J relationships


robertdah
 Share

Recommended Posts

I need to create a self-join relationship, but I just do not understand them and how to impliment them. What are the key fields and what they need to be i.e. pk or fk or nothing.

 

I have tried a buch of times and have read at least 5 books on the topic and still don't "get it". If someone could please explain it to me with a super simple example I would be indebted.

 

Thanks in advance.

 

Robert

Link to comment
Share on other sites

A self-join is when you relate a table to itself using one or more fields

(so table1::field1 to table1::field2 or table1::field1 to table1::field1).

 

What are you trying to achieve? What kind of file are you building? and what do you mean by "pk or fk"?

 

maarten

Link to comment
Share on other sites

pk and fk mean primary nad foriegn key respectively. It's convention.

 

I am making a database to hold all my stock transactions, buys , sells, Long and Shorts. They all have common fields except for Long sells and Long buys as example. So there is no need to have a bunch of tables, just portals to look at and add data. But I'll be damned if I can make a self join work. When I match table a::field 1 to table a1::field 1 my portal doesn't even see the relationship or if it does the portal is empty.

 

Robert

Link to comment
Share on other sites

Well I don't know about convention. It usually just means jargon.

 

Anyway. It depends on what you want to match. If you need to see all records in a portal that match any key, the match field on the left side should probably be a global (maybe linked to a menu items list holding possible match values, probably based on field values of the match field on the right side).

A self join works quite the same way a relationship between separate tables works. Just think of it as separate tables, you'll get two Table Occurrences (allright, TO's by convention) in the relationship graph anyhow.

If you want to see all records that match a particular field in a record, then relate that field "to itself". You must realize though that match keys are very particular. Mostly white space is the culprit. So you might have defined working relationships, but there is no match even though there are seemingly identical field values. "Long" and " Long " are different.

So a- clean up the match fields using Trim( ) and TrimAll( ) b- use value list for data entry as much as possible if the fields must act as match key. c- use as many auto-generated ID keys for matching as possible.

 

maarten

Link to comment
Share on other sites

here's a small sample.

 

there's a deliberate typo in one of the records to show what it does to your match.

 

maarten.

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use