Correct way to wire a 5V relay using BC547
The first diagram is correct. The second one will &quot;sort-of&quot; work with enough base drive because the transistor is in inverse mode. The low beta will mean that 10K is too high for it to work reliably.
If I was to guess what happened with your tests, perhaps you used the incorrect pinout for the &quot;European&quot; BC547, which is just the reverse of the typical US part:

Japanese parts such as (2S)C8015 have a third standard pinout in TO-92.