SQL&下线构建器应用程序的数据库设置

发布于 2024-10-30 08:25:22 字数 1293 浏览 0 评论 0原文

我目前正在为需要下载构建器或其他东西的客户构建一个网站。基本上,它是一个带有注册表单的网站,每个成员都有一个包含他们的推荐 ID 的 referral-url,因此当有人加入时,他们会被放置为下线成员,以某种<金字塔结构。

网站本身包含一个包含其他传销类型网站链接的页面,因此刚刚加入的人将属于某人的下线,并且将显示其他传销网站的推荐链接 strong> 以及各自的传销网站上线推荐 ID

如果这些新成员决定跟随他们的上线也成为其他传销网站的成员,他/她可以将这些网站的网址替换为传销计划的推荐网址。这一切都非常简单并且相对容易构建。

棘手的部分一旦新会员没有关注他/她的某个传销计划的上线,如果是这种情况,则下线该新成员将看到新成员上线的推荐ID或层次结构中第一个输入其推荐网址的成员

例如下图中的 Mr Brown仅加入计划 1 和 2。 2 他的下线看到了所有三个计划,但其中一个仅加入计划 2 和 2。 3 这意味着对于计划 3,他的直接上线将是 Brown 先生的上线。(参见紫色线)。

在此处输入图像描述

这部分是我不确定如何做到这一点,没有复杂的递归查找,如果有人退出或离开该网站?

有没有办法使用SQL 或任何其他技术进行此类查找。我想到在表格的一列中存储一个“路径”,包含每个新成员的上线血统,这样就可以相对容易地找到父母、祖父母等在。但您仍然需要递归通过此路径找到第一个带有推荐网址的路径。此外,如果您从树中删除某人,所有路径都需要更新以反映新情况。

树的深度和宽度没有限制。

我希望这不会太令人困惑。顺便说一句,这不是愚人节玩笑,我真的希望它是......

I'm currently building a site for a client who wants a downloadbuilder or something. Basically it's a site with a signupform and every member has a referral-url that contains their referral-id so when someone joins they are placed as downline member in a sort of pyramidal structure.

The site itself contains a page with links to other MLM type sites, so the person who just joins will be in the downline of someone and will be shown the referral links to other MLM sites with the referral-id of his upline for the respective MLM sites.

If these new members decide to follow their upline and become also member of the other MLM sites he/she can replace the urls to these sites with their referral-urls for the MLM programs. This is all pretty straightforward and relatively easy to build.

The tricky part is once a new member doesn't follow his/her upline for a certain MLM program, if that's the case the downline of this new member will see the referral-ids of the upline of the new member or the first in the hierarchy who did enter his referral-url.

For example Mr Brown in the image below, joins only program 1 & 2 his downline sees all three programs but one of them join only program 2 & 3 this means that for program 3 his direct upline will be the upline of Mr Brown.(see purple line).

enter image description here

It's this part that I'm unsure about how can I do this, without complex recursive lookup and what if someone quits or leaves the site?

Is there a way to do such a lookup with SQL or any other technique. I thought of storing a 'path' in a column of a table with the lineage of the uplines for each new member so it's relatively easy to find the parent, grandparent and so on. But still you need to recursively go through this path to find the first one with a referral-url. Also if you delete someone from the tree all paths need to be updated to reflect the new situation.

There's no limit to how deep or wide the tree can become.

I hope this is not too confusing. And btw it's NOT an April fools joke, I really wish it was...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风向决定发型 2024-11-06 08:25:22

我想你知道在介绍Z先生(由布朗先生推荐)时,Z先生是布朗先生的下线。我还假设您存储了此推荐信息。

当您向 Z 先生展示所有计划时,当 Z 先生注册某个计划时,您可以简单地浏览推荐信息并确定该人是否注册了同一计划。如果是,那么您可以将下线信息链接存储到 Mr. Browns 计划 1 记录。如果布朗先生没有注册,那么使用推荐数据,您可以走到推荐布朗先生的人处并进行检查。

希望这是有道理的,我对 MySql 不太熟悉,但是使用代码递归地执行此操作应该很容易。一些示例伪代码:

int GetUplineProgramId(User, ProgramID)
     Select All ProgramID's that the person who referred me signed up for
     If my referred is signed up for program, then return that record ID
     else return GetUplineProgramId(my referrals UserID, ProgramID)
end

I assume you know when presenting Mr. Z (who is referred by Mr. Brown), the Mr. Z is downline of Mr. Brown. I'll also assume you store this referral information.

When you show Mr. Z all programs, when Mr. Z signs up for a program, you could simple walk the referral information and determine if that person has signed up for the same program. If Yes, then you can store the downline information link to Mr. Browns Program 1 recoord. If Mr. Brown is not signed up, then using the referral data, you could walk to who referred Mr. Brown and check the same.

Hopefully that makes sense, I am not familiar enough with MySql, but using code it should be pretty easy to do this recursively. Some sample psuedo code:

int GetUplineProgramId(User, ProgramID)
     Select All ProgramID's that the person who referred me signed up for
     If my referred is signed up for program, then return that record ID
     else return GetUplineProgramId(my referrals UserID, ProgramID)
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文