Is there an assumption that only the latest pet is alive? Also, can one person own more than one pet at a time? Can one pet belong to multiple people at a time?

hgun77

Graduate

Posts: 164

Loc: Malaysia

3+ Months Ago

yeap, I am interest on alive people or pet only.one people can who many pets at same time. one pet can only belong to one people.

joebert

Fart Bubbles

Posts: 13506

Loc: Florida

3+ Months Ago

You could plop a newest_pet_id column on tbl_people linked to id in tbl_pets. Then update that column when a new pet is aquired/born. When their newest pet dies the column can be nulled out indicating no newest living pet.

hgun77

Graduate

Posts: 164

Loc: Malaysia

3+ Months Ago

thx brother, will use ur approach

UPSGuy

Lurker ಠ_ಠ

Posts: 2733

Loc: Nashville, TN

3+ Months Ago

This is almost guaranteed to have some kind of error (it's 8am and I haven't had my caffeine yet!), but it's heading down the right path. It should return the latest pet from each owner's group of pets.