CS 3723/3721
Programming Languages
Database Design, with Prolog


Database Design: excerpt from a database book (diagram in PDF):


Extended Prolog Example:

The Prolog below reproduces the situation described above. The two sets of Prolog "facts": suppliers and supplies are the same as the "proper" way to do database management in the write-up above. These are the Prolog analog to "normalized" relations in database terms. The code below illustrates that one can easily construct the "bad" relation sup_info from the two that are provided. The Prolog code also illustrates how to print information. (In the code below, Prolog tries to match up the information in a rule. The the final presense of fail in the rule tells Prolog to try to match a different way. Because there are write in these rules, a side-effect of the matching is to print the data.)

In the listing below, boldface black is user input, blue is the Prolog source, and red is the output from the Prolog program. (In the final listing, I added few extra tabs by hand.)


Revision date: 2004-03-19. (Please use ISO 8601, the International Standard Date and Time Notation.)