In a Thoroughbred’s pedigree it is pretty simple as Vinery pointed out;
XYZ horse is by, Sire‘s name, out of Dam‘s name, by Dam’s Sire’s name, going farther back, out of ( Grand dam’s name), by (Sire’s name of the Grand dam) out of (Great grand dam’s name) by (Sire of the great grand dam) etc.
The male line, top line is only mentioned once as is the top male line of the dam sire. Everything after that is the tail female line only, the very bottom line of a multiple generation pedigree.
So for this mare, http://www.pedigreequery.com/loved4 which we own, a 5 generation pedigree would read like this; Loved, by Pulpit out of Dearest by Riverman, out of Glowing Tribute by Graustark, out of Admiring by Hail to Reason, out of Searching, by War Admiral, out of Big Hurry by Black Toney out of La Troienne.
I threw in the 6th generation for an example of a mare’s tail female line that traces back to the often mentioned blue hen mare La Troienne.
This is a great example of line breeding that worked out very well, http://www.pedigreequery.com/sea+hero Sea Hero won the Kentucky Derby and was bred by one of the great private breeders Paul Mellon . Sea Hero was a top race horse but unfortunately he was not much at stud and was latter sold to Turkey. As you can see the bottom line, tail female, of his sire Polish Navy traces to La Troienne as does his dam, Glowing Tribute.