嵌套登录的Mysql数据库设计(登录后再登录)

时间:2022-10-19 23:52:26

In my application there are two users Manager and Team. Here in it in first login i'm checking that user is manager or team member. I'm checking it through user_type. So,

在我的应用程序中有两个用户Manager和Team。在第一次登录时我在检查该用户是经理还是团队成员。我正在通过user_type检查它。所以,

## User's table ##
----------
--> fieldnames

'user_id' 'username' 'email' 'password' 'user_type' (if 1 = user is manager , 0 = user is team member )
Row 1 -> '1' 'abc' 'abc@gmail.com' 'abc' '1' (user_type = 1 so Manager)
Row 1 -> '2' 'def' 'def@gmail.com' 'abc' '0' (user_type = 0 soTeam Member)


## Team's table ##
----------
--> fieldnames

'team_id' 'teamname' 'teamcode' 'user_id' 'user_type' 
Row 1 -> '1' 'TeamName1' 'AFE1(0' '1' '1' 
Row 2 -> '2' 'TeamName2' 'BCD@1(' '2' '1'

(So, TeamName1 is added by abc user and he is a Manager.

(因此,TeamName1由abc用户添加,他是一名经理。

  • Unique code (AFE1(0) is send to manager's email address and it's teamcode then manager will individually give to team members

    唯一代码(AFE1(0)发送到经理的电子邮件地址,然后是团队代码,经理将单独提供给团队成员

    and now i'm stuck about team's uniqueness because Member can logout from one team and login through another team's unique code and join another team)

    现在我对团队的独特性感到困惑,因为会员可以从一个团队退出,并通过另一个团队的独特代码登录并加入另一个团队)

  • SQLFiddle with the above data...

    SQLFiddle与上面的数据...

Note : Team Code is generated when a user is registered as a Manager.

注意:当用户注册为Manager时,将生成Team Code。

  • Unique code is send via email to manager . then manager will individually give that team code to the team member.
  • 唯一代码通过电子邮件发送给经理。然后经理将单独将该团队代码提供给团队成员。

  • and at the time of joining the team the team member will insert team code and then team member can join team.
  • 在加入团队时,团队成员将插入团队代码,然后团队成员可以加入团队。

  • after joining the team manager can allocate task to the manager. Give feedback to the team member.
  • 加入团队经理后,可以将任务分配给经理。向团队成员提供反馈。

  • And Team member can logout from one team and join another team.
  • 团队成员可以从一个团队退出并加入另一个团队。

Above process is after login as a team member or as a Manager.

以上流程是以团队成员或经理身份登录后。

So, My question is there is a Nested login (One login after another Login and task allocation process is based on "teamcode")

所以,我的问题是有一个嵌套登录(一个登录后另一个登录和任务分配过程基于“teamcode”)

So, I'm confused about the database structure because teamcode is also unique and team_id is also unique ?

所以,我对数据库结构感到困惑,因为teamcode也是唯一的,team_id也是唯一的?

2 个解决方案

#1


1  

As i understand manager can be part of team member of other team, and also team member is part of manager of other team.

据我所知,经理可以成为其他团队成员的一部分,而团队成员也是其他团队经理的一部分。

so you can not store user type in user table. so you need 3 table

所以你不能在user表中存储用户类型。所以你需要3张桌子

1) user : store user info like name email ect..

1)用户:存储用户信息,如姓名电子邮件等。

2) team : store team info like 'team_id' 'teamname' 'teamcode'

2)团队:存储团队信息,如'team_id''teamname''teamcode'

3) association : associate user and team with there roll (associationId, user_id, team_id, rollType)

3)关联:关联用户和团队与roll(associationId,user_id,team_id,rollType)

if you want to store different password for each association then add password in association table.

如果要为每个关联存储不同的密码,请在关联表中添加密码。

when manager add one team then make entry in team with teamcode as well as associate it using insert entry in association table user_id = manger's user id team id you just created rollType 1 (user_type = 1 so Manager).

当管理员添加一个团队然后使用团队代码在团队中进行输入,并使用关联表中的插入条目关联它user_id = manger的用户ID团队ID您刚刚创建了rollType 1(user_type = 1 so manager)。

when manager create one user as team member them insert it in user table if it's not user of you system and associate it with rolltype 2.

当manager将一个用户创建为团队成员时,如果它不是您的系统用户,则将其插入到用户表中,并将其与rolltype 2关联。

if that user is already in user table than just associate it no need to enter it in user table.

如果该用户已经在用户表中而不仅仅是关联它,则无需在用户表中输入它。

so when user login you can get the list of team with there roll using associate table.

因此,当用户登录时,您可以使用关联表获取团队列表。

#2


0  

You have to run a check query for each login process whether a team member is already exist in one of other teams tables. İf there is a record for him then do your restrictions.

您必须为每个登录过程运行检查查询,无论团队成员是否已存在于其他一个团队表中。如果有他的记录然后做你的限制。

#1


1  

As i understand manager can be part of team member of other team, and also team member is part of manager of other team.

据我所知,经理可以成为其他团队成员的一部分,而团队成员也是其他团队经理的一部分。

so you can not store user type in user table. so you need 3 table

所以你不能在user表中存储用户类型。所以你需要3张桌子

1) user : store user info like name email ect..

1)用户:存储用户信息,如姓名电子邮件等。

2) team : store team info like 'team_id' 'teamname' 'teamcode'

2)团队:存储团队信息,如'team_id''teamname''teamcode'

3) association : associate user and team with there roll (associationId, user_id, team_id, rollType)

3)关联:关联用户和团队与roll(associationId,user_id,team_id,rollType)

if you want to store different password for each association then add password in association table.

如果要为每个关联存储不同的密码,请在关联表中添加密码。

when manager add one team then make entry in team with teamcode as well as associate it using insert entry in association table user_id = manger's user id team id you just created rollType 1 (user_type = 1 so Manager).

当管理员添加一个团队然后使用团队代码在团队中进行输入,并使用关联表中的插入条目关联它user_id = manger的用户ID团队ID您刚刚创建了rollType 1(user_type = 1 so manager)。

when manager create one user as team member them insert it in user table if it's not user of you system and associate it with rolltype 2.

当manager将一个用户创建为团队成员时,如果它不是您的系统用户,则将其插入到用户表中,并将其与rolltype 2关联。

if that user is already in user table than just associate it no need to enter it in user table.

如果该用户已经在用户表中而不仅仅是关联它,则无需在用户表中输入它。

so when user login you can get the list of team with there roll using associate table.

因此,当用户登录时,您可以使用关联表获取团队列表。

#2


0  

You have to run a check query for each login process whether a team member is already exist in one of other teams tables. İf there is a record for him then do your restrictions.

您必须为每个登录过程运行检查查询,无论团队成员是否已存在于其他一个团队表中。如果有他的记录然后做你的限制。