There is a database schema guide in the documentation on this site. Group chat messages are stored in the database if history is enabled for rooms. Simple messages between users are not saved by default. You have to install Monitoring Service plugin and enable saving for that. Not sure where exactly in the database this plugin stores messages. Something like ofConversation, etc.