Murder Mystery

Another fun puzzle, based on the problem No. 55 in [PFJ86] and published as a challenge by Decision Management Community.

Someone in Dreadsbury Mansion killed aunt Agatha. Agatha, the butler, and Charles live in Dreadsbury Mansion, and are the only ones to live there. A killer always hates, and is no richer than his victim. Charles hates no one that Agatha hates. Agatha hates everybody except the butler. The butler hates everyone not richer than aunt Agatha. The butler hates everyone whom Agatha hates. No one hates everyone. Who killed Agatha?

The idea — as in previous posts — is to use concept of predicates, constraints, relations, and Continue reading “Murder Mystery”

Reindeer Ordering

The Decision Management Community posted a fun challenge: Santa’s elves are supposed to order nine reindeer according to a set of rules. The rules are:

  1. Comet behind Rudolph, Prancer, and Cupid.
  2. Blitzen behind Cupid.
  3. Blitzen in front of Donder, Vixen, and Dancer.
  4. Cupid in front of Comet, Blitzen, and Vixen.
  5. Donder behind Vixen, Dasher, and Prancer.
  6. Rudolph behind Prancer.
  7. Rudolph in front of Donder, Dancer, and Dasher.
  8. Vixen in front of Dancer and Comet.
  9. Dancer behind Donder, Rudolph, and Blitzen.
  10. Prancer in front of Cupid, Donder, and Blitzen.
  11. Dasher behind Prancer.
  12. Dasher in front of Vixen, Dancer, and Blitzen.
  13. Donder behind Comet and Cupid.
  14. Cupid in front of Rudolph and Dancer.
  15. Vixen behind Rudolph, Prancer, and Dasher.

The challenge is to create a decision model, but Continue reading “Reindeer Ordering”

MySQL Type Horrors

Although it is possible to demonstrate the problem in another DB system, I have deliberately chosen MySQL for this article because it literally lends itself to this kind of errors.

Example

A small, but powerful example. Just by looking at this you may guess that this post may have something to do with case sensitivity, but as you will see the problems go much deeper. Continue reading “MySQL Type Horrors”

Contradiction in Database [2]

The previous post focused on a contradiction in general; in this one I present a specific example using PostgreSQL.

Example

Starting with a predicate:
[p_1] Country named (CNAME) is assigned country code (CC2) and number (CID).

Country {CID, CC2, CNAME}
    KEY {CID}

Country (CID, CC2,  CNAME   )
      { (1,  'CA', 'Canada' )
      , (2,  'FR', 'France' )
      , (3,  'DE', 'Germany')
      , (4,  'DE', 'Denmark') -- typo
      }

Take a look at the sketch and the DDL. This is a common find: the ID is used as a primary key and there are no other constraints.

Consider the tuple with CID = 4; it has a wrong country code for Denmark, which results in a contradiction. From tuples with CID = 3 and CID = 4 it follows:

  • Country code DE is assigned to country named Germany.
  • Country code DE is assigned to country named Denmark.

In this case the contradiction is a result of the typo and Continue reading “Contradiction in Database [2]”