def get_trace_component_for_rule(rule_db, trigger_instance_db):
    """
    Returns the trace_component compatible dict representation of a rule.

    :param rule_db: The rule to translate
    :type rule_db: RuleDB

    :param trigger_instance_db: The TriggerInstance with causal relation to rule_db
    :type trigger_instance_db: TriggerInstanceDB

    :rtype: ``dict``
    """
    trace_component = {}
    trace_component = {'id': str(rule_db.id), 'ref': rule_db.ref}
    caused_by = {}
    if trigger_instance_db:
        # Once RuleEnforcement is available that can be used instead.
        caused_by['type'] = 'trigger_instance'
        caused_by['id'] = str(trigger_instance_db.id)
    trace_component['caused_by'] = caused_by
    return trace_component