![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all! I am trying to create an database for relation between parents and their children. I started with these Entities: Parent Child Parent_Child (parent_id fk, child_id fk) But this will only show relation between one parent and one child, so I thought I could set up the Entity Parents to manifest the relation between 2 parents. It's here my theory gets little rusty. When I model this I struggle to see that it's correct Parents Entity (Example): parents_id (PK) parent_id (FK) parent_id (FK) The second problem I struggle with is that a parent could have children with more than one other parent. This I don't quite get a grip of. So if somebody have some pointers for I will appreciate it |
#3
| |||
| |||
|
|
On Sat, 05 May 2007 06:30:05 -0700, dnomade wrote: Hi all! I am trying to create an database for relation between parents and their children. I started with these Entities: Parent Child Parent_Child (parent_id fk, child_id fk) But this will only show relation between one parent and one child, so I thought I could set up the Entity Parents to manifest the relation between 2 parents. It's here my theory gets little rusty. When I model this I struggle to see that it's correct Parents Entity (Example): parents_id (PK) parent_id (FK) parent_id (FK) The second problem I struggle with is that a parent could have children with more than one other parent. This I don't quite get a grip of. So if somebody have some pointers for I will appreciate it Your initial table set-up, with one minor change, will suffice. The change is to use as the primary key for your Parent-Child table the combination of parent-id and child-id. This will permit you to quickly access all of the children of any parent. (If you are using an RDBMS that doesn't require tables to have primary keys -- no changes are required.) This will also solve your second problem -- but retrieval will be slow since the entire Parent-Child table will have to be searched to find all of the parents of a child. If performance is an issue you can add a secondary index on child-id. HTH Jerry-the-bookkeeper |
#4
| |||
| |||
|
|
Hi all! I am trying to create an database for relation between parents and their children. I started with these Entities: Parent Child Parent_Child (parent_id fk, child_id fk) But this will only show relation between one parent and one child, so I thought I could set up the Entity Parents to manifest the relation between 2 parents. It's here my theory gets little rusty. When I model this I struggle to see that it's correct Parents Entity (Example): parents_id (PK) parent_id (FK) parent_id (FK) The second problem I struggle with is that a parent could have children with more than one other parent. This I don't quite get a grip of. So if somebody have some pointers for I will appreciate it |
#5
| |||
| |||
|
|
dnom... (AT) gmail (DOT) com> wrote in message news:1178371805.871661.147370 (AT) h2g2000hsg (DOT) googlegroups.com... Hi all! I am trying to create an database for relation between parents and their children. I started with these Entities: Parent Child Parent_Child (parent_id fk, child_id fk) But this will only show relation between one parent and one child, so I thought I could set up the Entity Parents to manifest the relation between 2 parents. It's here my theory gets little rusty. When I model this I struggle to see that it's correct Parents Entity (Example): parents_id (PK) parent_id (FK) parent_id (FK) The second problem I struggle with is that a parent could have children with more than one other parent. This I don't quite get a grip of. So if somebody have some pointers for I will appreciate it First off, should you have an entity called "persons"? Can't a person be a parent and also a child (of a different person, of course). |
#6
| |||
| |||
|
|
On May 5, 11:26 pm, "David Cressey" <cresse... (AT) verizon (DOT) net> wrote: dnom... (AT) gmail (DOT) com> wrote in message news:1178371805.871661.147370 (AT) h2g2000hsg (DOT) googlegroups.com... Hi all! I am trying to create an database for relation between parents and their children. I started with these Entities: Parent Child Parent_Child (parent_id fk, child_id fk) But this will only show relation between one parent and one child, so I thought I could set up the Entity Parents to manifest the relation between 2 parents. It's here my theory gets little rusty. When I model this I struggle to see that it's correct Parents Entity (Example): parents_id (PK) parent_id (FK) parent_id (FK) The second problem I struggle with is that a parent could have children with more than one other parent. This I don't quite get a grip of. So if somebody have some pointers for I will appreciate it First off, should you have an entity called "persons"? Can't a person be a parent and also a child (of a different person, of course). David Cressey: How will this help? I can't see that this will help to fin the relation between a parent and the other parents he/she has children with. Could you please explain it for me please Thanks in advanced David |
#7
| |||
| |||
|
|
Hi all! I am trying to create an database for relation between parents and their children. I started with these Entities: Parent Child Parent_Child (parent_id fk, child_id fk) But this will only show relation between one parent and one child, so I thought I could set up the Entity Parents to manifest the relation between 2 parents. It's here my theory gets little rusty. When I model this I struggle to see that it's correct Parents Entity (Example): parents_id (PK) parent_id (FK) parent_id (FK) The second problem I struggle with is that a parent could have children with more than one other parent. This I don't quite get a grip of. So if somebody have some pointers for I will appreciate it A child can only have 2 Birth parents, a mother and a father. You have |
![]() |
| Thread Tools | |
| Display Modes | |
| |