Say I cough on my table, then someone else touches it and picks up something I've got... how is it that these things can live outside the body, how long can they manage it, and how long is generally 'safe' to consider something no longer carrying these germs?
It depends entirely on the environment the virus or bacterium is in and also the size of it.
With regards to viruses, the most important thing is typically whether or not the virus has an outer membrane or envelope.
Non-enveloped viruses such as rhinoviruses, noroviruses and adenoviruses can in fact survive for long periods outside the host (up to several days) whereas viruses with membranes such as HIV, influenza and the herpes viruses which do well in the host survive for shorter time periods.
Experiments with rhinoviruses and influenza viruses have shown potential survival times ranging from a few minutes to 48 hours or more. They remain active longer on stainless steel, plastic and similar hard surfaces than on fabric and other soft surfaces.
This is because many enveloped viruses rely on the proteins on the surface of the membrane to attach to the host cell, this envelope is generally sensitive to degradation to sunlight and normal cleaning procedures.
Outbreaks associated with the non-enveloped viruses can continue for many months due to their relative stability in the environment, think of winter vomiting outbreaks, hand foot and mouth in animals as good examples of this phenomenon.
Because bacteria can undergo metabolism, synthesise proteins etc. for themselves, their life span is usually longer. If we split them into gram positive and gram negative its easier to discuss. Gram positive bacteria have a protein coat that prevents drying allowing them to survive longer. An example is the bacteria Staphylococcus aureus, which is responsible for toxic shock syndrome, food poisoning, and wound infections. With its protein coat it can withstand temperature and humidity extremes. The spore may survive for weeks on dry clothing using sloughed skin cells for food. The Bacillus anthracis, the anthrax bacteria, can also form spores and survive tens to hundreds of years. This is in comparison to gram negative which need humidity. An infamous example is Escherichia coli which survives typically only a few hours at best.
Viruses really take to heart the idea of "quantity, not quality." Like animals and plants, viruses and bacteria are a Completely different ball game (even more so than animals and plants).
As you maybe know, you have bacteria floating around you in the air right now. Realistically, a single T4 bacteriophage (a type of virus) has a life cycle of about 20-30 minutes at 37 °C. However, in this time period, it often reproduces in a bacterium and creates tens if not hundreds more phage particles using the bacterium like a machine that was hacked to do its bidding.
The only way to prevent a virus from attacking is through vaccinations and other preemptive measures, as it is so difficult to prevent reproduction.
Bacteria are so different they, for all intensive purposes, cannot be approximated. For a rough approximation, somewhere from hours to weeks.
Virus particles (virions) are not alive. They are just a Genome Delivery Vehicle. They are essentially like landmines. However like different types of landmines different types of viruses can remain "active" for longer or shorter.
Those depend as explained above on the virion structure but also on Humidity and temperature, the fomite (surface) and the ammount of virions. Some viruses need up to 10k Virons to cause disease. The higher this "Particle to PFU ratio" is the lower the chance they can remain active outside the body for long. So if the Virus in question needs few particles, is not enveloped then this one can in theory live for quite a while outside, Norovirus for example is one of those.