A database is also exceptionally good at doing transactional stuff like atomically incrementing something. I'd even say: This is something that belongs in the database and not in some brittle application logic.
MYSQL - https://stackoverflow.com/questions/449346/mysql-auto-increm...
POSTGRES - https://stackoverflow.com/questions/2095917/sequences-not-af...
thanks!