Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8695637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:05:13+00:00 2026-06-13T01:05:13+00:00

I have a table with UserId and ManagerId. When Editing this table I need

  • 0

I have a table with UserId and ManagerId. When Editing this table I need to make sure that
if Jim is Jills manager, and Ron is Marks manager, then I should not be able to set Mark as Jim manager, because it would create in infinate loop. I want to validate a form that can set a Manager field to a UserId.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:05:14+00:00Added an answer on June 13, 2026 at 1:05 am

    I dont see an infinite loop there… Ron is Marks manager, Jim is Jills Manager. If you set Mark as Jims manager, then you would have a linear tree of management. Ron->Mark->Jim->Jill. No need for recursion 🙂

    I understand what your trying to accomplish, but more information would give better insight to help you. Are these Employees a class or an entity of a table?

    I’m assuming each employee will only have one manager. Therefore, when setting an employee as another’s manager, progress up the linear tree to see if it would be valid, like so:

    //Assume managerName is "Mark" and employeeName is "Jim", as in your example above
    public bool isManagerValid(string managerName, string employeeName)
    {
        bool valid = true;
        var manager = getEmployee("Mark"); //The "to-be" manager of Jim
        var employee= getEmployee("Jim");
    
        var currentManager = getEmployee(manager.Manager); //Get Marks manager
        while(currentManager != null && valid)
        {
            if(currentManager == employee)
            {
                valid = false; //Some manager up the line from Mark is already Jim 
            }
            else
            {
                //Get the next manager up
                currentManager = getEmployee(currentManager.Manager);
            }
        }
        return valid;
    }
    

    I didnt attempt this in visual studios, typed it in here, so if there are any typo’s, please excuse me

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 fields that I need -> USERID LOCATION REPORT_MGR_USERID (reporting manager user
I have a table that stores user information. The table has a userid (identity)
I have a table called userstbl that has supId (supervisor) and has also userID
I have the following table UserID | User knows -------------------- a | b a
why select 'aaa' =0 return 1 (TRUE) if i have a table like userid
I have set up 2 two tables - table userid and table data in
I have two tables set up in phpmyadmin- table userid and table data. The
I have a table users with primary index userId . Currently, each user has
I have a table users which has a primary key userid and a datetime
I have a table as below dbo.UserLogs ------------------------------------- Id | UserId |Date | Name|

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.