Part 1.
If the following is true:
each Cow must be in exactly one Herd a Herd must have a sacredCow and a herdLeader a sacredCow for a Herd must be a Cow in that Herd a herdLeader for a Herd must be a different Cow in that Herd
You can then implement these rules using this partial model:
Cow (cowID, herdID) (all mandatory columns) - primary key (cowID) - unique (herdID, cowID) - foreign key (herdID) references Herd (herdID) Herd (herdID, sacredCow, herdLeader) (all mandatory columns) - primary key (herdID) - foreign key (herdID, sacredCow) references Cow (herdID, cowID) - foreign key (herdID, herdLeader) references Cow (herdID, cowID) - constraint (sacredCow != herdLeader)
Note that FK relationships include herdID, not just cowID. This ensures that only those cows in the herd can become sacred bones or herdLeader for this herd.
This design makes things a little difficult to implement, but not impossible. Foreign keys on Herd must be set aside in a database such as Oracle, because we need to be able to insert rows for the herd before we can insert rows for the cow, and the Stud needs at least two cows (sacredCow and herdLeader).
Part 2.
The next task is to implement the following restriction:
only a Sacred Cow may be featured in a Cartoon
One way to do this is to split the cows into two separate relationships: SacredCows and NonSacredCows.
SacredCow (sacredCowID, herdID) (all mandatory columns) - primary key (sacredCowID) - unique (herdID, sacredCowID) - foreign key (herdID) references Herd (herdID) NonSacredCow (nonSacredCowID, herdID) (all mandatory columns) - primary key (nonSacredCowID) - unique (herdID, nonSacredCowID) - foreign key (herdID) references Herd (herdID) Herd (herdID, sacredCow, herdLeader) - primary key (herdID) - foreign key (herdID, sacredCow) references SacredCow (herdID, sacredCowID) - foreign key (herdID, herdLeader) references NonSacredCow (herdID, nonSacredCowID) Cartoon (cartoonID, featuredCow) (all mandatory columns) - primary key (cartoonID) - forign key (featuredID) references SacredCow (sacredCowID)
(In this construct, the constraint (sacredCow! = HerdLeader) is no longer required, because by definition they are now different cows.)