How to create serial nos in db, before insert. Can you help me with hooks?

I want to generate part nos. Like if 3 contents with the same title and the same author found then they will be listed as content (serial no- 1), content (serial no-2), content (serial no-3). So, the readers will be able to find the contents serial-wise.