Q:

Database with hierarchy and joins

I have a database that has three tables in. Each is a heigharcy of the other. The tables are Dog, Gender, Name.
The Dog table includes the name of the breed and an id. The gender table includes an id of the dog breed, and id, and the sex. The name table includes the dogs name, the the gender id and how old it is.
The relationship is set up in the following manner. Dog -> Gender -> Name. 
What would be the best way of pulling all the dogs names and sexes based off of just the dog id. I know i would have to use a join and I’m honestly not that proficient.
Psuedo code Ive came up with
JOIN NAME ON GENDER ON DOG. Is that correct?
DOG
id, name, gender id, age

1, Holey, 2, 7
2, Fluffy, 1, 3

GENDER
id, sex, breed id

1, male, 1 
2, female, 1 

NAME
id, name, breed id

1, male, 1 
2, female, 1 

A:

Your SQL should look like this:
SELECT Breed.Breed, Gender.Sex, Dog.Name FROM Dog 
JOIN Gender ON Dog.GenderID = Gender.ID 
JOIN Breed ON Gender.BreedID = Breed.ID
WHERE Dog.ID = 'YourDogIDHere'

And it would return the following:
Breed   | Sex   | Name
 --------|--------|-------
 Collie  | Male | Fluffy
 Collie  | Female | Holey
Edit: Edited to include breed and reorder columns.

