472,365 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,365 software developers and data experts.

Contact Management DB: Handling "Friends"?

I'm makeing a little DB to help manage high school class reunions.

One feature I'm trying to implement is "Friends". e.g. Fred Smith is a friend
of Joe Jones and Bill Anderson. We record that so that when Fred moves and
our mailing bounces, we can call Joe and/or Bill in hopes of getting Fred's new
address.

I started implementing this as just tblFriend linked to tblPerson on PersonID
plus another link to tblPerson on FriendID.

But now I realize that the data is far from Normal. Seems like when I add Joe
Jones as a 'Friend' of Fred Smith, the app should know that the relationship
goes both ways: i.e. Joe shows up on Fred's screen (as expected...) but Fred now
automatically shows up on Joe's screen.

Anybody been here?
--
PeteCresswell
Nov 13 '05 #1
6 2006
Greetings,

I have been there. My fix may be a bit of a kludge but it goes like
this

say that
Fred's ID = A123
Bill's ID = B234
Joe's ID = C345
Sue's ID = D456

tblPeople
MainPersonID, Friend1, Friend2, Friend3, Friend4
A123 B234 C345 D456
B234 A123
C345 A123 D456
D456 A123 C345

Normalized Version of tblPeople
MainPersonID, FriendID
A123 B234
A123 C345
B234 A123
C345 A123
C345 D456
D456 A123
D456 C345

The kludge is that there is no table containing just friend ID's. These
have to be manually associated as in the 2nd tblPeople. I'm sure there
is a way to dynamically associate the ID's. I just haven't come up with
that way. But this is how I handled a similar situation.

HTH

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #2
(Pete Cresswell) wrote:
I'm makeing a little DB to help manage high school class reunions.

One feature I'm trying to implement is "Friends". e.g. Fred Smith is a friend
of Joe Jones and Bill Anderson. We record that so that when Fred moves and
our mailing bounces, we can call Joe and/or Bill in hopes of getting Fred's new
address.

I started implementing this as just tblFriend linked to tblPerson on PersonID
plus another link to tblPerson on FriendID.

But now I realize that the data is far from Normal. Seems like when I add Joe
Jones as a 'Friend' of Fred Smith, the app should know that the relationship
goes both ways: i.e. Joe shows up on Fred's screen (as expected...) but Fred now
automatically shows up on Joe's screen.

Anybody been here?


No. But you could create a query. Add the Classmates table and Friends
twice. You should now have Friends and Friends_1. Drag a link from
Classmate to Friends on the PersonID on Friends. Then drag a link from
Classmate to FriendID on Friends_1.

Set the relationship to select All records from Classmates and only
matching records from Friends and Friends_1. (dbl=click on relationship
line)

You would want then want to modify the criteria so that you select the
Person from the Classmate file.

You would get the ID from Friends1 where the ID in Friends is not null.
In the next criteria line (OR) , where ID in Friend_1 is not null.

Or...you could modify this so that you UNION it between 2 queries.
Select all records with PersonID matches PersonID and PersonID matches
FriendID.
Nov 13 '05 #3
On Wed, 03 Nov 2004 16:02:29 GMT, "(Pete Cresswell)" <x@y.z> wrote:
I'm makeing a little DB to help manage high school class reunions.

One feature I'm trying to implement is "Friends". e.g. Fred Smith is a friend
of Joe Jones and Bill Anderson. We record that so that when Fred moves and
our mailing bounces, we can call Joe and/or Bill in hopes of getting Fred's new
address.

I started implementing this as just tblFriend linked to tblPerson on PersonID
plus another link to tblPerson on FriendID.

But now I realize that the data is far from Normal. Seems like when I add Joe
Jones as a 'Friend' of Fred Smith, the app should know that the relationship
goes both ways: i.e. Joe shows up on Fred's screen (as expected...) but Fred now
automatically shows up on Joe's screen.

Anybody been here?


I think the best answer is just to create 2 friendship records, one pointing
each way. If you need cascading delete, just set both relationships from
people to friends as cascade delete, and deleting either person, will then
delete both of the friend relations between that person and each of his/her
friends.
Nov 13 '05 #4
Pete:

A half baked idea for you to flesh out...

Assuming two tables

tblPerson
PersonID - pk
PersonName
etc

tblFriend
RelID - pk
PersonID - fk
FriendID - fk

create the following union query:

SELECT tblFriend.PersonID AS Person, tblFriend.FriendID AS Friend
FROM tblFriend UNION ALL SELECT tblFriend.FriendID AS Person,
tblFriend.PersonID AS Friend
FROM tblFriend;

that should get you a list of Person to Friend and the reverse
relationship you are looking for.

Now the half baked part...

I assume you will make a form to show the person data, with a subform
showing friends. The subform will use the union query as the record
source. You will have to manage adding and deleting relationships via
popups since you can't do that directly in the union query. Shouldn't
be a big deal but I'm sure there will be gotchas in there somewhere.

I'd be interested in the gotchas you run across if you use it. If you
don't I'd like to hear why you rejected the approach.

good luck

Tom

"(Pete Cresswell)" <x@y.z> wrote in message news:<91********************************@4ax.com>. ..
I'm makeing a little DB to help manage high school class reunions.

One feature I'm trying to implement is "Friends". e.g. Fred Smith is a friend
of Joe Jones and Bill Anderson. We record that so that when Fred moves and
our mailing bounces, we can call Joe and/or Bill in hopes of getting Fred's new
address.

I started implementing this as just tblFriend linked to tblPerson on PersonID
plus another link to tblPerson on FriendID.

But now I realize that the data is far from Normal. Seems like when I add Joe
Jones as a 'Friend' of Fred Smith, the app should know that the relationship
goes both ways: i.e. Joe shows up on Fred's screen (as expected...) but Fred now
automatically shows up on Joe's screen.

Anybody been here?

Nov 13 '05 #5
I've done this with

tblPeople
PeopleID
First
Last
etc.

tblRelationshipTypes
TypeID
Type (e.g. Friend, brother, employer, etc.)

Then I can record all types of relationships in
tblRelationships
PeopleID
IsRelatedTo (another PeopleID)
IsRelatedAs (use a TYPEID)
also a comment

My main frmPeople has a subform frmsubRelationships - and does a
lookup to Phone for the person also.
This does not do the union mentioned in a previous post, and that's
actually one thing I've been thinking about adding.

First, however, I'd like to solve the problem of adding a new person.
Since my control for "IsRelatedTo" is a dropdown, Not in List will
call a small form just for adding a person, address & phone.
Unfortunately, it often crashes the database. The only reason I can
think of is that frmPeople has tblPeople open already. When I call me
small frmAddPeople, I'm opening another copy of tblPeople. Should I
be opening a RecordsetClone? Will that let me save a new record? Or
is there a way to close the table before closing the pop-up?
Nov 13 '05 #6
RE/
SELECT tblFriend.PersonID AS Person, tblFriend.FriendID AS Friend
FROM tblFriend UNION ALL SELECT tblFriend.FriendID AS Person,
tblFriend.PersonID AS Friend
FROM tblFriend;

that should get you a list of Person to Friend and the reverse
relationship you are looking for.

Now the half baked part...

I assume you will make a form to show the person data, with a subform
showing friends. The subform will use the union query as the record
source. You will have to manage adding and deleting relationships via
popups since you can't do that directly in the union query. Shouldn't
be a big deal but I'm sure there will be gotchas in there somewhere.

I'd be interested in the gotchas you run across if you use it. If you
don't I'd like to hear why you rejected the approach.


Done. Works as advertised.

-----------------------
tblPersonFriend:
PersonFriendID (PK)
PersonID_A
PersonID_B
Comments
-----------------------
The union query returns tblFriend recs where PersonID_A
matches the currently-selected person and where PersonID_B matches same.

I feed the Union query to an Append query that loads that info into a work
table, putting PersonID_A or ..._B into the work table's PersonID as appropriate
and putting the other into FriendID. The subform's combo box's.ControlSource is
FriendID and it's .RowSource is a list of people by PersonID, excluding
whoever's record is currently being edited.

------------------
ttblFriend:
PersonFriendID
PersonID
FriendID
Comments
------------------

When Save time comes around, I run four queries:

- qryPersonSave_Friend1_AppendNew
- qryPersonSave_Friend2_UpdateExisting
- qryPersonSave_Friend3_IdentifyDeleted
- qryPersonSave_Friend4_RemoveDeleted
There's a little more processing with deleted recs.
This comes in the form of another work table that I didn't mention yet:

------------------------
ttblFriendDeleteTracker:
PersonFriendID
IsDeleted
------------------------

Right after I load ttblFriend, I load ttblFriendDeleteTracker
by copying info from the just-loaded ttblFriend.

Then, at Save time, I run an Update query that joins ttblPersonFriend to
ttblPersonFriendDeleteTracker on PersonFriendID and sets IsDeleted=True for recs
that have disappeared from ttblPersonFriend.

After that's done, I run a Delete query that joins ttblPersonFriendDeleteTracker
to tblPersonFriend on PersonFriendID and deletes tblPersonFriend recs where
IsDeleted=True.
Sounds like a lot of code, but it's pretty simple and executes in a flash.

Thanks.
--
PeteCresswell
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

93
by: jacob navia | last post by:
In this group there is a bunch of people that call themselves 'regulars' that insist in something called "portability". Portability for them means the least common denominator. Write your code...
7
by: seven.reeds | last post by:
Hi, I have a caontainer div that is 80% of the width of my display and 40em high. It will hold from 2 to 10 columns of data and will almost always have more than 40ems of lines... so it will...
1
Coldfire
by: Coldfire | last post by:
Hello I need a HTML script for Emailing the link, with description, of my site to any email address for-example in the case of "Share this Page with Friends". plz help
2
by: JohnQ | last post by:
Yeah, I'm a lil burnt out and need to go elsewhere. I'll go do that. I know how bad it gets when I mix livelihood.. no, I didn't mean that! I was harkening back to when I worked as a wage slave and...
84
by: aarklon | last post by:
Hi all, I found an interesting article here:- http://en.wikipedia.org/wiki/Criticism_of_the_C_programming_language well what do you guys think of this article....??? Is it constructive...
1
FLEB
by: FLEB | last post by:
I'm working on a PHP/MySQL site with social networking and "message blast" functionality, and I'm not sure what the best method to represent multiple levels of interpersonal relationships in the...
0
by: delhi institute of management & services | last post by:
Delhi Institute of Management & Services Dear friends, We are extremely happy to welcome you to the world of Management... We are in the process of preparing some 5 minutes revision Q & A type...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.