Assuming these are rules that relate to a policy of the organization in question - i.e. "all committee chairs must be a member of at least one other committee", or "no committee must have less than two members", then you should probably put them in Java. Java is a more flexible programming environment than SQL and an RDBMS.
Say your rule is "no committee chairman can be a member of any other committee". You might implement it like this:
public class Committee {
private Person chairman;
private Set<Person> members;
public Person getChairman() {
return chairman;
}
public void setChairman(Person person) {
for (Committee other : person.getMemberships() {
other.removeMember(person);
}
chairman = person;
addMember(person);
}
public void addMember(Person person) {
members.add(person);
person.addMembership(this);
}
public void removeMember(Person person) {
members.remove(person);
person.removeMembership(this);
}
public Set<Person> getMembers() {
return new HashSet<Person>(members);
}
}
public class Person {
private Set<Committee> memberships = new HashSet<Committee>();
public Set<Committee> getMemberships() {
return new HashSet<Committee>(memberships); // Return a copy, not the original
}
public void addMembership(Committee committee) {
memberships.add(committee);
}
public void removeMembership(Committee committee) {
memberships.remove(committee);
}
}
You could then write unit tests for Committee to verify that the rules for chairmanship are working, and they would run very fast, because they wouldn't need the database.
public class CommitteeTest {
@Test
public void testChairmanship() {
// Set up the initial conditions
Person person = new Person();
Committee other = new Committee();
Commiteee commitee = new Committee();
other.addMember(person);
committee.setChairman(person);
assertTrue(committee.getChairman().equals(person));
assertFalse(other.getMembers().contains(person));
}
}
(You might want to use a mock object for the Person, since this unit test is supposed to test only Committee.)
As you add more rules, you would add more unit tests, and then would continue to run fast.