Q:

How to enforce constraint which allows duplicates of three columns, but only when two columns match?

I have a SQL Table that contains entries that have to satisfy two constraints.  First there should be no duplicates with the same MID and Source.  Second, the combination of Source, ID, DBID must be the same for the same Source and ID.  The question is, how to enforce this second constraint?  Example table below:
MID Source  ID          DBID    Match   Accuracy
================================================
1   FILE    Alice (HD)  1       DIRECT  100%
1   TMDB    M-1201      2       NAME    95%
2   FILE    Alice (SD)  3       DIRECT  100%
2   TMDB    M-1201      2       ID      100%
2   IMDB    tt0048348   5       ID      100%
3   FILE    Unknown     4       DIRECT  100%
3   TMDB    null        null    null    null
4   TMDB    S-1201      1       NAME    92%
5   TMDB    null        null    null    null

The constraints would be something like:
UNIQUE(MID, Source)
CHECK THAT (Source, ID, DBID) are same for all (Source, ID)

So, the following records should result in:
MID Source  ID          DBID    Match   Accuracy
================================================
6   TMDB    M-1201      2       DIRECT  100%
--> Accepted (TMDB, M-1201, 2) matches existing (TMDB, M-1201, 2)
7   TMDB    M-1201      500     DIRECT  100%
--> Violates CHECK, as there already exists (TMDB, M-1201, 2) and 2 != 500
1   FILE    Something   501     NAME    95%
--> Violates UNIQUE, as there already exists (1, FILE)

I've tried normalizing Source, ID, DBID into a seperate table, but I'm then unable to check the UNIQUE constraint without duplicating information (leading to further constraints to make sure this doesn't get out of sync).
I'm using PostgreSQL, but would prefer a solution that is fairly portable -- I suspect EXCLUDE constraints might work for PostgreSQL, but I'm unsure how it could apply here.  According to the PostgreSQL documentation, CHECK constraints should only refer the current row, so I'm wondering if anything can be done about this at all.

A:

I've tried normalizing Source, ID, DBID into a seperate table, but I'm then unable to check the UNIQUE constraint without duplicating information (leading to further constraints to make sure this doesn't get out of sync).

Actually, that is the way to do it.
DBID depends on Source and ID, so it should live in a different table. That is how databases work and how normalization works. 
Source  ID          DBID
========================
FILE    Alice (HD)  1   
TMDB    M-1201      2   
FILE    Alice (SD)  3   
IMDB    tt0048348   5   
FILE    Unknown     4   
TMDB    S-1201      1   

With primary key (Source, ID)
MID Source  ID          Match   Accuracy
========================================
1   FILE    Alice (HD)  DIRECT  100%
1   TMDB    M-1201      NAME    95%
2   FILE    Alice (SD)  DIRECT  100%
2   TMDB    M-1201      ID      100%
2   IMDB    tt0048348   ID      100%
3   FILE    Unknown     DIRECT  100%
3   TMDB    null        null    null
4   TMDB    S-1201      NAME    92%
5   TMDB    null        null    null

If (MID, Source) is supposed to be unique, you could make that the primary key. Another option would be making (MID, Source, ID) the primary key and adding a unique constraint on (MID, Source). Whatever you decide to do, there should be a foreign key constraint on (Source, ID) referencing your first table.

