schema design question
-
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
-
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
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
-
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
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