I also built a dog genealogy site and store all 80,000 dogs in one table. Each dog has sire (father) and dam (mother). the id of each references back to the same table through a paternal field(could be father_id) and maternal field (could be mother_id)
There are no other relationships on the dogs apart from breeder and owner so all dogs under the same owner could be listed. But I have not found any need to hold downward looking relationships - just parents.
members of the same family could be considered as children with identical parents (full siblings)
here's most of the relationships that I have found I need, you might be able to take something from this;
public function mother()
{
return $this->belongsTo(Dog::class,'Maternal');
}
public function father()
{
return $this->belongsTo(Dog::class,'Paternal');
}
public function offspringOfMother()
{
return $this->hasMany(Dog::class,'Maternal','id');
}
public function offspringOfFather()
{
return $this->hasMany(Dog::class,'Paternal','id');
}
public function progeny() // this means children
{
if($this->Gender=='B'){
$query = $this->offspringOfMother();
return $query;
}
$query = $this->offspringOfFather();
return $query;
}
public function fullSiblings()
{
return Dog::where('Maternal', $this->Maternal)
->where('Paternal', $this->Paternal)
->where('id','!=',$this->id)
->orderBy('DOB', 'asc')
->get();
}
For instance;
http://borderterrier.org.uk/dogs/show/~m3lFYWpz?depth=4
This is the site in its pre-laravel form. I'm currently in the process of totally re-writing it using Laravel.