Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. schema design question

schema design question

Scheduled Pinned Locked Moved Database
databasequestiondesignxmlhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    ppp001
    wrote on last edited by
    #1

    Hi, I have two objects, both point to each other in OO. e.g. Class Father { private int id; //id of father private Son son; } Class Son { private int id; //id of Son private Father father; } so I need to have two tables in database as follow, Table Father : (id, SonId) Table Son : (id, FatherId) The problem is, should I eliminate the one of the reference in one of the table, e.g. Table Father : (id) Table Son : (id, FatherId) so I just have the fatherID in the son table. But if I remove the sonID from the father table, I need to join the two tables when I retrieve fathers from the father table. So what are the pros and cons of the two schema design ? Thanks

    D 1 Reply Last reply
    0
    • P ppp001

      Hi, I have two objects, both point to each other in OO. e.g. Class Father { private int id; //id of father private Son son; } Class Son { private int id; //id of Son private Father father; } so I need to have two tables in database as follow, Table Father : (id, SonId) Table Son : (id, FatherId) The problem is, should I eliminate the one of the reference in one of the table, e.g. Table Father : (id) Table Son : (id, FatherId) so I just have the fatherID in the son table. But if I remove the sonID from the father table, I need to join the two tables when I retrieve fathers from the father table. So what are the pros and cons of the two schema design ? Thanks

      D Offline
      D Offline
      Daniel Santillanes
      wrote on last edited by
      #2

      Analyze a bit... Without going into much trouble.. the relationship between father and son tables is as follows: A Father can have 1 or more sons, but a Son can only have a father at any one time. If you follow this, then only having idFather in the son table it's more than enough to make the searches you need. Anything else you need to add? daniero

      T 1 Reply Last reply
      0
      • D Daniel Santillanes

        Analyze a bit... Without going into much trouble.. the relationship between father and son tables is as follows: A Father can have 1 or more sons, but a Son can only have a father at any one time. If you follow this, then only having idFather in the son table it's more than enough to make the searches you need. Anything else you need to add? daniero

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        daniero wrote:

        Father can have 1 or more sons

        i would say so, but looking at his class definitions, a father have only one child :~ ppp001 wrote :

        Class Father {
        private int id; //id of father
        private Son son; <-- see what i mean
        }

        Class Son {
        private int id; //id of Son
        private Father father;
        }

        maybe a modeling mistake, but he wrote it !


        TOXCCT >>> GEII power
        [toxcct][VisualCalc] -- modified at 11:29 Wednesday 16th November, 2005

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups