  We derive the algebraic relations of alternating and non-alternating finite
harmonic sums up to the sums of depth~6. All relations for the sums up to
weight~6 are given in explicit form. These relations depend on the structure of
the index sets of the harmonic sums only, but not on their value. They are
therefore valid for all other mathematical objects which obey the same
multiplication relation or can be obtained as a special case thereof, as the
harmonic polylogarithms. We verify that the number of independent elements for
a given index set can be determined by counting the Lyndon words which are
associated to this set. The algebraic relations between the finite harmonic
sums can be used to reduce the high complexity of the expressions for the
Mellin moments of the Wilson coefficients and splitting functions significantly
for massless field theories as QED and QCD up to three loop and higher orders
in the coupling constant and are also of importance for processes depending on
more scales. The ratio of the number of independent sums thus obtained to the
number of all sums for a given index set is found to be $\leq 1/d$ with $d$ the
depth of the sum independently of the weight. The corresponding counting
relations are given in analytic form for all classes of harmonic sums to
arbitrary depth and are tabulated up to depth $d=10$.
