def METHOD_NAME(instance_name, project_id, properties, res_name):
    """ Creates a Cloud SQL database. """
    name = properties['name']
    res_name = '{}-{}'.format(res_name, name)
    db_properties = {
        'name': name,
        'project': project_id,
        'instance': instance_name
    }
    optional_properties = [
        'charset',
        'collation',
        'instance',
    ]
    for prop in optional_properties:
        set_optional_property(db_properties, properties, prop)
    database = {
        'name': res_name,
        # https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases
        'type': 'gcp-types/sqladmin-v1beta4:databases',
        'properties': db_properties
    }
    outputs = [
        {
            'name': 'name',
            'value': '$(ref.{}.name)'.format(res_name)
        },
        {
            'name': 'selfLink',
            'value': '$(ref.{}.selfLink)'.format(res_name)
        }
    ]
    return DMBundle(database, outputs)