The Business Rules Engine

Step 3: Create the Student Forms

Now that the address fields are taken care of, you turn your attention to the records for the students themselves. Which entity type is most appropriate for them, tables or forms?

At first glance, it doesn't seem like there is a whole lot happening with the student records. They are just created and updated, right? Well, maybe. But when do they get entered? When the student visits for the first time, or when they are accepted? What happens when they graduate; how do we keep track of that? You decide to create the students as a form with just two simple statuses.

CREATE FORM students (
     first_name STRING NOT NULL,
     last_name STRING NOT NULL,
     email_address STRING NOT NULL,
     home_address_id REFERENCE TO addresses NOT NULL,
     school_address_id REFERENCE TO addresses NOT NULL,
     phone_number STRING NOT NULL
) WITH STATUSES 
     ( entered, enter INITIAL ),
     ( removed,  remove );

ALTER FORM students 
     SET STATUS ORDER
     entered LEADS TO ( removed ),
     removed LEADS TO ( entered );

For the time being the workflow is pretty minimal; students enter into the system with the status "entered," but they can be toggled back and forth with removed as needed. That should keep Tina happy.

Oh, you forgot something!

You also want to keep track of each student's pets. This isn't really important data, but the university is small, and they pride themselves on making their community feel special. You decide that this data probably doesn't merit a whole new table, though.

ALTER FORM students
   ADD FIELD pets STRING ARRAY NULL;

Thankfully CodaServer has an array type that makes this so easy.

You're almost done!