If you ask for military advice, you'll typically get a lot of missinformation, as well as a lot of unneccesary micromanagement. This is a simple guide to a fairly effective mility, without too much micromanagement.
Tips for a successful military:
1. Long Patrol Duty: Unless you are actually giving long patrol orders, this is a bug. No amount of being off duty will fix this. You need the binary patch to fix it, or just offset the unhappiness somehow. I recommend the patch. It also fixes some other annoying military bugs.
2. Training Orders: You don't need a mess of 2 man squads. Customize your training alert schedules to be 5 sets of train minimum 2 orders. You'll get more sparring, and more effective training this way. You only have to set up the order once, then just copy it across the schedule.
3. Equipment: For melee, this is very important. Set up a custom uniform, containing 1 metal breastplate, 1 metal mail shirt, 1 metal helm, 1 metal gauntlets, 1 metal leggings or greaves, 1 metal high boots, 1 shield (material doesn't matter too much here), and 1 weapon. Set to replace clothing. Set to wear when off duty. Make sure to assign it to your whole squad(s) using Shift + enter. I generally don't bother with my archers, they shouldn't get hit too much anyway.
4. Schedule: I see no reason to have my troops ever off duty. Some people do. It's up to you, but the only benefit will be an improvement of civilian skills, with some occasional stat boosts.
5. Barracks: All squads need a barracks, assigned at least to train. I generally build a barracks for each squad, not sure how important this is. I never use any of the other barracks designations, just train. It seems to work just fine for melee dwarves.
6. Archery Training: Build an archery target for each marksdwarf, assign each one as a range, set the correct direction, and assign each one to a squad. Also build 1 barracks for the whole squad, in the same room as the targets. Marksdwarves seem to train more often when off duty, for some reason. I generally train my marksdwarves on local wildlife, and this prevents a need for hunters... make sure to produce plenty of bolts.
7. Ammo: Make sure you have enough quivers for your archers. Make sure to have plenty of bolts. There seem to be bugs when storing ammo in bins, I've gotten much better results by not allowing bins in my ammo stockpile. But that means it needs to be relatively large.
8. Dwarf Selection: Sending your untrained peasants into the military sounds like a good idea. But due to another bug, there's a problem with that. When a dwarf with no civilian skills is taken off active duty, they get an unhappy thought. When an order ends, or is cancelled, military dwarves temporarily get reverted to civilians. This means constant unhappy thoughts. So I typically make all peasants work mining detail until they have some skill, then move them into the military. The other consideration regarding dwarf selection is that females will carry their babies into battle with them, which often results in the baby dying, and unhappy dwarves. So I don't draft any females.
9. Jobs: My military dwarves have no other jobs enabled. The big 3 to avoid are hunting, mining, and woodcutting. When assigning a military dwarf, make sure you have disabled at least those three jobs. I just disable them all, for simplicity's sake.
A good practice is to constantly churn out armor sets and weapons, once you have a metal industry going. I usually set up one metalsmith with each armor piece on repeat, and another with weapons on repeat. Your dwarves will automatically take better quality equipment as it becomes available, and your armorer and weaponsmith will get lots of practice. The lower quality armor and weapons make excellent trade goods.
This is a fairly simple military setup, which achieves pretty good results without too much micromanagement. You can go above and beyond, and hunt out dwarves with good personality traits to be squad leaders, and put your best teachers as squad leaders, but I don't bother. I leave my front door wide open, and meet sieges at the gate, with pretty low casualties, so this is effective enough for the most part.
If anyone has anything they think I should add, or correct, please let me know. I think once this is looked over I might put it up on the wiki, as a companion for the current military guide.
Edit: Added note about female dwarves and babies in the military