Is it true that we can estimate the mass of a star more accurately if it has a companion star? I remember I hear a theory that if a star has a companion star, we can know the mass of the star more easily, is that true? if it is true, while I understand that by measuring the period of the companion star, we can know the mass ratio of 2 stars,but how can the companion star also help to measure the mass of parent star?
In general, masses can only be precisely estimated for stars in binary systems (asteroseismology and some other indirect techniques can yield estimates too).

There are two broad types of binary where this is possible - astrometric binaries, where the motion of both stars can be seen on the sky and where the distance to the binary is known (e.g. Sirius AB); or eclipsing binaries, where the stars eclipse each other and their motions are inferred from their line of sight velocities, measured by spectroscopy (e.g. YY Gem).

You are correct, that the relative motions of the stars only yields their mass ratio. What is needed to get the individual masses is something that fixes the absolute sizes  of the orbits and the orbital period, which can then be used with Kepler's third law to give the total mass of both stars and hence combined with the mass ratio to give the masses of the individual components. 

In astrometric binaries you can measure the angular size of the orbits and calculate an absolute size using the known distance. In close (unresolved) binaries, that size is inferred from the velocities and orbital periods, but also requires knowledge of the inclination of the orbital plane. This is known quite accurately (is close to 90 degrees) only for eclipsing binaries.

I could present the Maths if you really like, but these are quite standard results.