I think triggers are your only option, here.
On 11/9/09, Sebastiaan van Erk <sebster@stripped> wrote:
> I have the following model:
> Domain (*)<-(1) Account (*)<-(1) User
> That is, each user belongs to exactly 1 account, an account can have
> multiple users; each account belongs to a single domain, and a domain
> can have multiple accounts.
> A user has an email address, which must be unique across the domain
> (since it's used to log into that domain: on login you select the domain
> and then enter your email and password).
> However, the email address need *not* be unique across different
> domains. Thus, I want the following combination to be unique:
> (Domain.id, User.email)
> Is there any way I can do this without duplicating the domain id in the
> User table?