def add_dtable(se, key, value):
    """Add a DTABLE entry to the SE and the optmodel

    Parameters
    ----------
    key : str
        The DTABLE unique key. The algorithm automatically attempts to add
        a sufix to prevent repeated keys.
    value : float
        The value corresponding to `key`.

    Returns
    -------
    key : str
        The resulting key.

    """
    optmodel = se.model.optmodel
    origkey = key
    if key in optmodel.dtables.keys():
        if len(key) >= 8:
            raise ValueError('{0} is an already existing DTABLE entry!'.
                             format(key))
        if key in optmodel.dtable_prefixes:
            optmodel.dtable_prefixes[key] += 1
        else:
            optmodel.dtable_prefixes[key] = 0
        sufix = str(optmodel.dtable_prefixes[key])
        key = key + sufix.rjust(8 - len(key), '0')
        if len(key) > 8:
            raise ValueError('Use a smaller key')

    if origkey in se.dtables.keys():
        raise
    se.dtables[origkey] = [key, value]
    optmodel.dtables[key] = float(value)

    return key