Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2010
    Posts
    1

    Unanswered: I need help to create family tree in SQL databases

    This is my task
    Create a SQL database with one table “Relations”. Use this table to store family-tree data relations such
    as:

    a.John Doe
    i. Mary Doe
    ii. Mathew Doe
    1. Sarah Doe
    a. John Doe Jr.
    b.Michele Young
    iii. Mike Young

    Write down a stored procedure to find out a path to the oldest relative for pointed person. As example,
    result from the stored procedure for Mary Doe (path: a-i) should be Mary Doe < John Doe.

    Try out to print the result in reverse order (from oldest to the youngest): John Doe > Mary Doe.

    NOTE: Do not use cursors.
    I created table like:
    create table RELATIONS
    (
    ID VARCHAR(5),
    NAME VARCHAR(100),
    RELATION_ID VARCHAR(5)
    )
    I need help very quickly
    Last edited by vesnac; 04-16-10 at 04:15.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by vesnac View Post
    I need help very quickly
    What's the rush? Is there a deadline to the assignment?

    The optimal solutions might only be able to be run in SQL Server. Are you studying T-SQL or ISO SQL?

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by vesnac View Post
    Write down a stored procedure to find out a path to the oldest relative for pointed person.
    it would make a wee bit more sense if you had shown the actual indentation for the nesting like this --
    Code:
    a.John Doe
         i. Mary Doe
        ii. Mathew Doe
               1.  Sarah Doe
                      a.  John Doe Jr.
    b.Michele Young
         iii. Mike Young
    have a look at this -- Categories and Subcategories

    everything you need to for the assignment is there
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    Judging from the use of Varchar2, I would say he is using Oracle. If that is the case, then a cursor should be acceptable, as it is not nearly the resource hog on Oracle as it is on SQL Server.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by MCrowley View Post
    ...a cursor should be acceptable
    not if the homework assignment specifically rules it out

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •