How to choose the right transistor for a circuit and its associated resistor?
I'm assuming you mean a BJT (NPN or PNP) and not a FET (N-channel or P-channel.)
I'm also assuming that you mean the base current limiting transistor.

You have to choose a transistor that has sufficient voltage and current rating for your load.
For example, for a 12V relay coil, that may spike to 24V during inductive transients, use a 30V rated transistor.
For a coil with a current rating of for example 80 mA, choose a transistor that is rated for at least that (although almost any transistor in a discrete package will be rated for at least that much.)

Finally, for the base current limiting resistor, look at the hFE of the transistor (let's say it's 10) and divide the load current (80 mA) by that (giving 8 mA.) Then look at the voltage you have driving the transistor, and the base-emitter voltage drop. The voltage that's left (say, 3.5V) divided by the base resistor should equal at least that current. Use Ohm's law. To drop 3.5V when delivering 8 mA, you need (3.5/0.008) 437.5 Ohms; better choose something slightly less.

In general, you want to memorize Ohm's law, and use it to analyze any kind of load/voltage/current question you have, as it's one of the most basic properties of electronics. You also want to actually read about and understand the components you're using, such as resistors (why does the wattage rating matter?) and transistors (what is hFE, what is voltage drop, etc.)