Database Design Help: Whose Child Is It Anyway

I am creating my female Contact Manager program as a fun exercise in teaching Silverlight 4. It will track people's addresses, phone numbers, emails, special occasions (birthday, anniversary, etc.).

Along the way, I hit a minor road hit while developing the database. She would like to be able to group Contacts (people) by Family, so I created a table Familiesthat has FamilyIDand FamilyDescription, and then added FamilyIDto the table People.

Now SELECT * FROM People WHERE FamilyID = 2will return everyone in this particular family.

I think , this is an acceptable idea; where I struggle, however, how to include children, as in children. We have a very large family, so the family will have many children. I just add them to the People table, if so, how can I distinguish children from adults?

I am very grateful for your understanding, thank you.

+3
source share
5 answers

PEOPLE.familyid , , - -. , , , , ...

" ", PEOPLE FAMILY:

PEOPLE_FAMILY_MAP

  • PEOPLE_ID ( , PEOPLE.id)
  • FAMILY_ID ( , FAMILY.familyid)

- (type_code, description) , :

  • PERSON_ID ( , PEOPLE.id)
  • RELATED_TO_PERSON_ID ( , PEOPLE.id)
  • RELATIONSHIP_TYPE_CODE ( , RELATIONSHIP_TYPE_CODES.RELATIONSHIP_TYPE_CODE)
+8

" " , PeopleId?

, !

, ? , . , .

, , .

WPF- - http://www.vertigo.com/familyshow.aspx

+2

Level People .

: -2, -1, / 0, ( ) 1, 2 ..

.

0

- , , " "... , , ... .. , . , ...

, . . , , , , ... ( , familyX.relationtype = ...)

.

0

, .

, - , . , . ( , ).

:

:

  • FamilyId

Then just get the mapping table:

  • Familyid
  • Personid
  • Role

the role can be any of the following ("Head of the family" (the so-called decadents - otherwise, the dollar stops there), "Peony")

Then for Mr. and Mrs. Johnson you can have the "The Johnsons" family. but if you want to spam all your relatives, you use "The Johnsons extended"

0
source

Source: https://habr.com/ru/post/1761858/


All Articles