A Part of Judy's Example


Two of the three refactorings of your example I had programmed (and had to make some wee generalizations).  I was pleased that I could crank this out without too much difficulty.  The figure below is the example I have implemented:



Let's start at the top.  There are 3 files for PD1:
Next, there are 3 files for PD2:
And the three files for PD3:

Let me show you the program that does all this.  There are 3 Java classes.  Konstants.java contains constants and arguments to the PullUp and Normalization refactorings:
package judyexample;

import CR.AbstractClass;
import CR.Normalize;

public class Konstants {
    final static String cdspec1 = "test/TestData/PD1.cdspec.pl";
    final static String schema1 = "PD1.schema.pl";
   
    final static String cdspec2 = "PD2.cdspec.pl";
    final static String schema2 = "PD2.schema.pl";
   
    final static String cdspec3 = "PD3.cdspec.pl";
    final static String schema3 = "PD3.schema.pl";
   
    static AbstractClass.Args args1 = new AbstractClass.Args("Entity","Person","Dog");
    // pull up shared fields into abstract class Entity from subclasses Person and Dog

    static Normalize.Args args2 = new Normalize.Args("ae", "Address", "addr", "Entity", "livesAt", "zipcode","state");
    // Normalize "Entity" by creating and Address class with (zipcode and state) fields.  The association that
    // connects Entity to Address is named "ae", the role with Address is addr, the role of Entity is livesAt
}



Rider Level

Here is the Rider (Schema) level program:

package judyexample;

import CR.AbstractClass;
import CR.Normalize;

public class RiderLevel extends Konstants {
   
    public static void main(String... args) throws Exception {
        // Step 0: input data is hard-coded for this example
       
        // Step 1: create schema for PD1 (schema1)
        M4.CDSpec2Schema.main(cdspec1);
       
        // Step 2: refactor PD1 to PD2, and create schema for PD2
        AbstractClass.PullUp(cdspec1, cdspec2, args1);
        M4.CDSpec2Schema.main(cdspec2);
       
        // Step 3: refactor PD2 to PD3, and create schema for PD3
        Normalize.Normalize(cdspec2, cdspec3, args2);
        M4.CDSpec2Schema.main(cdspec3);
    }
}

Briefly the actions are:

Camel Level

Here is the Camel (database) level program:

package judyexample;

import CR.AbstractClass;
import CR.Normalize;

public class CamelLevel extends Konstants{
   
    public static void main(String... args) {
        // Step 0: input data is hard-coded for this example
       
        // Step 1: refactor data.PD1.pl to data.PD2.pl
        // <input.oldschema.pl> <outSchema.schema.pl> <out.outschema.pl>  args
        AbstractClass.PullUpDB("data.PD1.pl","PD2.schema.pl","data.PD2.pl",args1);
       
        // Step 2: refactor data.PD2.pl to data.PD3.pl
        Normalize.NormalizeDB("data.PD2.pl","PD3.schema.pl","data.PD3.pl",args2);
    }
}
Briefly the actions are:

Bottom Line: I am delighted that I could produce this example quickly, from what I've been working on these last few days.  I didn't believe I could do it this quickly.