I was wondering how to express a dictionary or associative array (as known in programming) formally in mathematical notation. A dictionary is basically a set of ordered pairs of keys and values, but each key must appear only once.
Now, if $K$ is the set of all possible keys and $V$ the set of all possible values, my first idea of how to express a dictionary over $(K,V)$ was: $$D \subseteq \{(k,v)\mid k \in K \land v \in V\}$$
The problem is that this allows for repeated keys. So my second idea was this:
$$D \subseteq \{(k,v)\mid k \in K \land v \in V \land \forall (q, w) \in D: k=q \to v=w \}$$
Is this a sensible definition of a dictionary or am I missing something crucial?