Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Self-referential database objects

The post title is a bit of a misnomer, but here we go.

There is an object in our database called Users. It has an ID, let's call it User_ID.

A User may refer someone else to use our application, thus creating a new user.

The actual referral is tracked in the system in a table most remarkably called 'User_Referral'. As far as this question is concerned, this table contains two user IDs, let's call them Referrer_ID and Referred_ID

My question is, how do I write a script that allows me to intelegently discuss 'Users' as an entire entity, as well as 'referrers' and those who were referred as distinct entities (bearing in mind that any given user may be either, neither or both)

2 Replies
johnw
Champion III
Champion III

I'm not sure if it's exactly what you need here, but you may want to look into a semantic load. Here's an example that tracks parent and child records.

Not applicable
Author

hi,

its is a good example, but when i tried with another example it is not working.