We’re skipping ahead a bit because this reduction is from the same paper as last week’s (and reduces from last week’s problem).

**The problem: **Prime Attribute Name. This is problem SR28 in the appendix.

**The description: **Given a set A of attribute names, and a collection F of functional dependencies like in the last problem, and a specific attribute x in A, is x in some key K for the relational system <A,F>? (Recall that keys need to be of minimal size).

**Example: **Using the example from last week- the list of attributes was {Name, ID, Course, Professor, Time}. The functional dependencies were:

- ({Name},{ID}) (If you know a student’s name, you can figure out their ID)
- ({ID},{Name}) (If you know a student’s ID, you can figure out their name)
- ({Name, Course}, {Professor, Time}) (If you know a student’s name and a course they are in, you can figure out the professor teaching it and what time the course is)
- ({Professor, Time), {Course}) (If you know the professor of the course and the time it is being taught, you can figure out the course being taught. Note that you can’t figure out the student because more than one student will be in the course)

Recall that we said the pair of attributes {Name, Course} was a key for this system. (So, if x was “Key” or “Course”, a solver for this problem should answer “yes”.) But since Name and ID are related, ID is also a prime attribute. I think Professor and Time are *not* prime, because any subset of A that includes them and has the required characteristic is not minimal (If you take Professor, you’d have to add two other things- for example Course and ID).

**Reduction: **This reduction is in the same paper that has the Minimum Cardinality Key reduction, and in fact reduces from Minimum Cardinality Key. Their terminology differs from what I typically use, but I’ll try to do it their way to be close to the paper.

The MCK instance starts with a set of attributes A’, a set of relations D[0]’ (what they call F), and a key size m (what we call k). We need to build an instance of the PAN problem: a set of attributes A, a new set of functional dependencies D[0], and a specific attribute we want to check: b (what our definition calls x).

First, they define a set A”, which is “a set whose cardinality if the smaller of |A’| and m”. (I guess of all new elements). They define A to be A”xA’ unioned with A’ unioned with a new attribute b. They define D[0] with the following characteristics:

- For all subsets E and F of A’, if E relates to F in D[0]’, E unioned with B relates to F in D[0]
- A’ unioned with b relates to A”xA’
- for each ordered pair (i,e) in A”xA’, b unioned with (i,e) relates to e.
- for each element i in A’ and all distinct e,f in A, the set {(i,e), (i,f)} relates to b.
- Each element e in A’ relates to b.

The idea now is that if D[0] has a minimal key that contains b, you need a bunch (N) of the (i,e) sets as well in the key to distinguish which ones relate to b. Then the A’ part of the ordered pair gives you n elements in A’ that are a key for A’.

If A’ has a key of cardinality n <= m, then we know that A” has at least n elements, and adding b to the pairs of items in A’ and A” gets you a key for A.

Also, b has to be in the key for A, since removing it gets you a set that is not D[0] expandible,

**Difficulty: **9. This is really a lot to digest. I’m not entirely sure I get what’s happening myself.