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

  • SEARCH
  • Home
  • 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 968667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:31:16+00:00 2026-05-16T02:31:16+00:00

This is a fairly simple question (or at least from the outset it should

  • 0

This is a fairly simple question (or at least from the outset it should be).

I am looking into efficient ways to model a One to Many relationship where the many is the same type.

Example

Say we have a Person Entity, and this person has 0 to many Sub-Persons, and the Sub-Persons have 0 or 1 Parent-Person.

The answer should take into consideration read optimization & querying simplicity from Linq to Entity Framework. Answers relating to underlying Database table structure for best read performance are also very welcome (as long as they can be mapped to by EF4).

  • 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-05-16T02:31:17+00:00Added an answer on May 16, 2026 at 2:31 am

    This looks like a case of self-referential foreign key. (oracle)

    A generally used example is the Employee-Manager relationship.
    A given employee can be a manager (to other employees) and can in-turn have a manager (or not, if he is the boss).

    The table definition and constraint definition would be like this.

    CREATE TABLE EMP
    (
      EMPNO     NUMBER(4)                           NOT NULL,
      ENAME     VARCHAR2(10 BYTE),
      JOB       VARCHAR2(9 BYTE),
      MGR       NUMBER(4),
      HIREDATE  DATE,
      SAL       NUMBER(7,2),
      COMM      NUMBER(7,2),
      DEPTNO    NUMBER(2)
    )
    

    and the constraint would be ..

    alter table emp add constraint fk_emp_mgr
    foreign key mgr references emp(empno);
    

    This indicates that the manager Id for a given employee must himself be an employee.
    Here is the sample data.

    EMPNO ENAME JOB MGR
    
    7369 SMITH CLERK 7902
    7499 ALLEN SALESMAN 7698
    7521 WARD SALESMAN 7698
    7566 JONES MANAGER 7839
    7654 MARTIN SALESMAN 7698
    7698 BLAKE MANAGER 7839
    7782 CLARK MANAGER 7839
    7788 SCOTT ANALYST 7566
    7839 KING PRESIDENT 
    7844 TURNER SALESMAN 7698
    7876 ADAMS CLERK 7788
    7900 JAMES CLERK 7698
    7902 FORD ANALYST 7566
    7934 MILLER CLERK 7782
    

    As you can see, all employees have a manager (except KING who is the company’s boss.).
    each of them is in turn an employee.

    Note that this is a model that is suitable and perfect for OLTP style systems. There is no redundant data and data integrity constraints are taken care of.

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

Sidebar

Related Questions

This should be a fairly simple question to answer, but I am interested to
I think this should be a fairly simple question for anyone who knows PHP.
This should be a fairly simple question. Essentially, I believe there's a good chance
I believe this is a fairly simple question but it is something I am
fairly simple question and I haven't seen anything asked with this exact scenario laid
This might be a simple question, but I'm fairly new to PHP and am
I'm fairly new to Android programming, so this may be a simple question, but
This question is fairly fundamental.I gave a simple and straighfoward test on my cygwin:
I know this must be a fairly simple question, but I haven't managed to
I am sure this is a fairly simple question but I can't seem to

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.