Yeah so this is pretty simple.
Possibly quick answer -- DB (defensive back) is just what is used to describe both cornerbacks and safeties, so the short answer is no. of cornerbacks plus no. of safeties = number of DBs.
Traditionally base defenses have been 4-3 or 3-4. Those numbers tell you no. of lineman and number of linebackers. So 4-3 has 4 lineman, 3 linebackers.
Both the 4-3 and 3-4 will have 4 DBs -- two safeties and two corners.
In nickel, typically one linebacker is replaced by a corner back, giving you 5 (hence nickel) DBs. A team that uses a 3-4 as its base defense will use a 3-3-5 nickel (3 linemen, 3 linebackers, 5 DBs).
A 4-3 team will use a 4-2-5 setup - 4 linemen, 2 LBs, 5 DBs.
Same thing for dime, replace a linebacker with a cornerback.
Edit: Here are some pictures:
Nickel defense: