Primary Key allows duplicates

Why does the primary key allow for duplicates?

That said, the _id column, which is also a primary key, does prevent duplicates.

I’m trying to prevent duplicate emails for one of my tables.

Brett, what Wix calls a Primary Key !== primary key in its accepted meaning. Wix´s Primary Key should have been called “Unique Display Key for Content Manager Only” or something likewise.
A short breakdown:

  1. reference fields take, as a reference, the only unique id (called _id) that is available (good). As proof, look at documentation: every ref_field on an Insert should carry the _id, and NOT the so called Primary Key
  2. the Primary Key has one, and only one function: in a 1-n database relation, n has a reference to 1 by _id, as stated above.
  3. because this _id is visually pretty meaningless, Wix Content Manager (you know, the database grid) does this: fetch from n the above 1 (=fetch from detail the master) by _id
  4. look inside Master table schema what was defined as “Primary Key”
  5. DISPLAY this so called key (to make things more readable)

In short: Wix Primary Key only has a meaning inside Content Manager, it´s not a Primary Key (but _id is), it is NOT NO_DUPS, and yes, the name Primary Key is extremely confusing (coming from relational db´s).

Does this make any sense? It took me quite a while to figure this out, hope it helps.