views:

40

answers:

2

I'm currently planning a piece of software for dogbreeders and I'm in doubt about my datadesign...whether I'm doing something smart or stupid :)

The plan at the moment is one holistic "dog" table sorta like this...

Id | Name | FatherId | MotherId
-------------------------------
1  | A    | NULL     | NULL
2  | B    | 1        | NULL
3  | C    | NULL     | NULL
4  | D    | NULL     | 3
5  | E    | 1        | 3
6  | F    | 5        | 2
7  | G    | 4        | 3

My questions is, is it common to make it like this or is it really sloppy. I can see a quick lookup reason to have it but I'm really in doubt whether it's good or bad in the end. I thinking it would be better designed if I had a rel-table on the side with Id coupling, but I'm really in doubt how well any of the cases are.

A side note is that it'll only be me personally looking at the data this way (or someone adopting the project from me)

+3  A: 

This is a perfectly valid relational database design, you would probably be looking at doing self-joins to query the data.

David Neale
I got the concept of how to use it, was more curious if it was a good idea, what's the downfall of the different methods of doing it.
cyberzed
Ah I see. I've had a bit of a search on any disadvantages to using this design but I can't find any. I've used it many times in my own designs.
David Neale
If those zeroes for FatherId and MotherId mean "unknown", you might want to make them NULL instead. Otherwise, you'd need to make an entry for Dog 0, the unknown parent, who would then be both the mother and father.
Philip Kelley
@Philip my bad ... ofcourse unknown parent is supposed to be NULL
cyberzed
A: 

Your design is fine. Parent to child is not a many-to-many relationship so there's no need for a separate link table.

Zarigani