The major scale of C is built of 2 equal tetrachords (= four step ladders) of 2 whole steps and a half step): W W H 8notice that between the 2 tetrachords is another whole step.
=> C D EF and G A BC = W W H (W) W W H
(the half- the half steps are made visible by the closer distance).
notice that between the 2 tetrachords is another whole step (WHW). Thus the major scale has the pattern: W W H (W) W W H whereby (W) is referring to the whole step between F and G, the whole step between the two tetrachords.
The relative names of a major scale are Do Re MiFa So La TiDo (mifaMiFa and tidoTiDo are the halftone steps, Ti is called leading tone to Do, Fa leading tone to Mi)
You can now develop all the scales of the sharps by using first the second tetrachord of the C ( scale:so la tido becomes the do re mifa of a new scale with the root note G. We get G A BC and D EF G.
The first tetrachord G A BC is now built identicallike the first tetrachord of the C scale and can be replaced as 1 2 34 ... but the half step of the second tetrachord EF is between the 6th and 7th degree 5 67 8 and we have no leading tone from 7 to 8. By augmenting the 7 degree with a sharp # we construct the leading tone and solve the problem of the half step between 6 and 7. (5 6 78) We have a new upper tetrachord with a halftone between 78 with 1 # (F#). Continuing ths operation the upper tetrachord will become the lower one of the next key in the direction of the circle of 5ths clockwise.
CB A G ... FE D C (ToTiDoTi La So FaMi Re Do)
FE D C and build a new scale with the root tone F. The upper tetrachord of F major is useful but the lower has a problem: CB A G F is not congruent with So FaMi Re Do. We need to flatten the B to Bb (a half tone lower) and get a whole tone between the upper and the lower tetrachord: FE A G (W) BbA G F and we have also construct the new leading tone Fa to get a half tone to Mi (or Me) BbA. That's the explaining why the scale of F major has 1 b-flat. Following this principal the lower tetrachord of F (BbA G F) will become the upper of the new scale Bb-major with two flats (Bb and Eb) etc.