I've never done something quite like this before. In terms of recording this into a database, I would first take the user to an OGM where it collects/asks the user for his/her id code when he/she calls in, save that to a variable to use later. Then ask if they are logging in or out and simply save "in" or "out" to a variable like %inout% based on the user input. then you can keep it simple and use the built-in feature in the OGM properties window to write a line to a log txt file with what ever text and variables you wish (at some point you would have had to randomly select whether voice id was requested (see below) and store the boolean or yes/no in a variable).
Example:
Log format:
%user% logged %inout% on %date% at %time% Voice ID: %voiceRequested%
1075 logged in on 2007-02-22 at 09:30:26 Voice ID: No
6724 logged out on 2007-02-22 at 17:10:14 Voice ID: Yes
Alternatively you could use a plugin to interface with a more sophisticated database. In terms of the random requests to record his or her name, you would have to use the the plugin on NCH's website with random functions. However, I'm not sure how you would control which OGM the user is sent to based on the result of the random number, I haven't done that before, and I'm not sure, but it seems like it should be possible.