Depth of field brackets on cameras are quite handy to start a discussion about picking the right aperture to get a desired depth of field and suggest the concept of the hyperfocal distance. I wish more lenses had them. I've got an old Vivitar Series One lens that has a quite pleasant set of depth of field brackets that work at any zoom length. Modern zoom lenses don't even try to get this right.
While a depth of field scale is quite useful, everything you learn at the beginning about hyperfocal distance and depth of field is not always correct.
A lot of gonzo shooters and beginners don't realize that lenses tend to lose image quality at various aperture ranges.
A lot of measurebators realize it too well and run endless tests on lenses wide open, even if they never shoot that wide open. See, the fastest way to tell the quality of two lenses apart is to shoot wide open, because around f/8, you won't be able to tell lenses apart.
Basically, and I don't feel like I need to get into die hard technical detail, all but the most perfect lenses will lose quality when used wide open. And all lenses, excepting futuristic meta-material lenses not yet made, suffer from diffraction and therefore lose quality when used heavily stopped down.
The numbers on the wide-open side vary depending on the lens. If you take a bunch of 50mm lenses for 35mm / APS-C cameras and shoot them at f/2.8, you probably can't tell much difference. For cheap zooms, you may have to go all the way to f/8. In theory, one could make a lens that is fanatically sharp all the way open, but being diffraction-limited is more a buzzword than anything else.
It largely depends on your sensor size, so you might want to run some tests. My G7 is sharpest at f/4. 35mm cameras tend to start getting soft about f/11 and my RB67 can go up to maybe f/22.
There's even an optimum aperture for pinhole photography, by the way.
The depth of field scale on a camera usually lies to you. It's usually calibrated for being reasonably sharp on 8x10 prints. And that's fine, because when you don't have the time to really think about what you are doing, it probably only matters that you've got a decent 8x10.
There are two ways to look at it. First, you can make a reasonable guess at the final resolution of your system and desired enlargement size and run it through a correct depth of field calculator.
Alternatively, you work out the correct aperture for the highest possible resolution. The ever-famous Ken Rockwell has a well-written article that explains his set of calculations.
Me? I'm not totally concerned. I generally just stop down at least one stop farther than what the DoF scale would suggest and get on with it.
Okay, so you've sat down in a scene. You've worked out the range of the scene that needs to be in focus. Then you've applied the maximum-sharpness conversion. And then you realize that you are well past the point of diffraction with your camera setup or maybe the shutter speed is so slow that you are going to have unwanted motion blur. Oops.
You've got a few options.
The best, of course, is to twist your camera like a pretzel, assuming it's got bellows and movements in useful locations. But most cameras don't and breaking cameras because you can't get a shot is not the act of a mature adult.
You may be able to accept that you just won't be able to blow the shot up as far as you'd like.
Or you can start re-allocating your sharpness. Maybe you want to emphasize the foreground, but only so much. So maybe you can open it up so that you are at the hyperfocal distance for an 8x10 print (maybe use the depth of field brackets) but so that the more interesting foreground is at maximum sharpness. Unless you really know what you are doing, it is generally better to have the background be out of focus, not the foreground.
You can focus bracket and fix it up in Photoshop, which I don't have the attention span to get right.
Or, finally, if you are up against a motion-blur limit instead of a sharpness limit, you can spray-and-pray. There's a story of Galen Rowell taking pictures of a bed of flowers on a windy day. Everybody thought he was nuts but, after spending an indeterminate amount of film on the flowers, one of them turned out to be perfectly sharp.