Q:

How to make one link in a many-to-many relationship primary?

Let's say I have a table of products (product) and a table of categories (category) and between them there is a many-to-many relationship via a supplementary table (product_category_xref).
Is there a way to make one, and only one category "primary"?
So far I have two ideas:

Create a separate column in the product table, primary_category, and have it contain a key for the primary category.
What I don't like about this is that either there will be redundancy in data (same category defined in both primary_category and product_category_xref) or category matching (verify vs. primary_category and vs. product_category_xref.category).
Create is_primary, a boolean column in product_category_xref.
What I don't like about this, is that potentially there's a way to make several categories primary.

Also, integrity of a many-to-many relationship is enforced with foreign key, but I have no idea how to enforce only one primary category (or, perhaps, when a category is made primary, make all other categories of the same product non-primary).
What's the best way to do this?
UPDATE: The DBMS is MySQL interfaced via mysqli in PHP.
UPDATE2: Here's what I ended up doing.
I added a non-nullable integer column in the product_category_xref table, priority. The primary category is then where primary is maximum. As a useful side effect, I can also sort categories.
I also added the same thing the other way around to allow sorting the products within a category.
Sure, this makes it harder to update the data, but that doesn't happen so often.

A:

I don't disagree with ypercube, who is suggesting this design will be effective (regardless of DBMS)

Note in this design there is an extra table that refers to your many-to-many table, so it has both product and category in it, but it's primary key is just product.  This design enforces these two requirements:

The primary product category is a valid product category combination.
There is at most one primary product category for each product.

This design doesn't help you with the constraint that every product must have a primary product category, which can really only be achieved by adding a mandatory foreign key column on the Product table.
However, I'm not sure that I would go so far as to recommend this solution to your problem.  While this design successfully imposes the constraints you're looking for, it won't actually be easy to work with in your code.  You're going to have to write code that deals with the fact that changes to product categories could impact your primary product category.  The design works well on the persisted state of the data but it does you no favours for data changes.
Since you're going to need some program logic to make changes to the data work, you might also consider a simpler database design (e.g. add the FK column Product.primary_category_id) and write program logic to impose the additional constraints.  It's not a fool-proof method, just a different, possibly easier to understand (therefore maintain) compromise.
Which way to go depends on how strongly you feel about pushing as many constraints as possible into your schema.

