Databases exam solution