Tutorial 03 – Project Tutorial
What We Learn
Deploying new content that extends the model, but does not add elements to existing objects. How yellow Role classes are converted to standalone links, how state tracking works for previously loaded data that does not exist in the source anymore, as well as how soft deletion can be implemented in the Model layer using parameters.
Modeling and mapping
Look at the structure and content of the ProjMaster.PROJECT, ProjMaster.PERSON_PROJECT and ProjMaster.PROJECT_ROLE tables in DS_DemoData.
You will come to the conclusion that the following steps need to be taken:
| Source table… | …goes to the Staging Area as… | …and maps to the Class |
|---|---|---|
| DS_DemoData.ProjMaster.PROJECT | ProjMaster.RAW_PROJECT | Project |
| DS_DemoData.ProjMaster.PROJECT_ROLE | ProjMaster.RAW_PROJECT_ROLE | Person’s role in project |
| DS_DemoData.ProjMaster.PERSON_PROJECT | ProjMaster.RAW_PERSON_PROJECT | Project membership |
In a new Project management subfolder, model the three new classes like below. Re-use the existing Person class, which leads to automatic integration of person data from both source systems.

Next decide on the keys: from the source data you can draw the conclusion that Project number is most likely the Business key for Project (the database table’s primary key is not of any help here), and Code would appear to be the Business key for Person’s role in project. Project membership, however, is worthy of a discussion.
Project membership represents a typical Participation pattern: something participates in some activity in a specific role during a specific period of time. It would make sense that the natural key in this case consists of the combination of the referenced classes as well as the Start date attribute, since a person could be in the same role in the same project during different times, or in different roles at the same time, and the key should be able to cater for all of these needs. It is technically possible that, even though the key feels logically sound, that some of the key values could change (for example, if someone corrects an error in the role, or if the person simply starts at a later date).
A change like this makes a hash key representing the same real world event to “change”, leaving us with two instances describing the same thing, but with slightly different details. To catch this, turn on State tracking for the Project membership class and set the Soft Delete parameter value to true after deployment. This can be done when we know we will always load the complete set of data representing the class. So in this case, we will always load all Project membership data, and we want to track when a previously loaded membership disappears for whatever reason. Note that soft deletion requires the state tracking to be active, but state tracking does not necessitate that you activate soft deletion.
To finalize the latest additions:
| Do this… | …and this happens |
|---|---|
| Set Project.Project number as Business key. | Project gets a hub. |
| Set the Person’s role in project.Code as business key. | Person’s role in project gets a hub. |
| Set the Non-Business key of Project membership to Person, Project, Role, Start date. | Project membership gets a link to represent it, not a hub. |
| Check Project membership’s Track state parameter. | A state tracking satellite will be created for the link. Whenever a previously loaded Project membership is missing from the source data, it is marked as Deleted (D) in this satellite. If the data reappears, it is marked as Created (C). A Soft Delete mechanism then hides all objects from the view layer that have been deleted and not subsequently recreated. |
| Set Implement to true for the three new classes. | They will be implemented. |
The Project membership key in the Key editor:

Open the existing ProjMaster mappings file and add the source columns to the mapping rows, and if needed, complete them with PK and FK info and the appropriate Class and Property names.
Save the project and build the entire model.
Try out an Ad Hoc diagram to verify your table structure. Start by selecting the Project management submodel in Models, click Open Implementation in ER Diagram, and then use the show/expand buttons in the diagram pane’s toolbar to work your way towards the structure below.

Deploy the changes & Soft Delete
In the Models pane, make a selection that contains the three new classes and deploy like in the previous tutorial. After deployment, during Step 2 below, select the Project membership class from the Models hierarchy, and set its Soft Delete parameter to true. Also try toggling the Soft Delete parameter on and off, and note that the corresponding view will react immediately by hiding or showing rows that are marked as deleted.

Run Tutorial Scripts
Run each of the tutorial script commands from the Help -> Tutorials -> DSharp Studio Professional Course -> Project Tutorial menu, and inspect the results.
| Script | Source data | Main points of interest |
|---|---|---|
| Step 1: Load initial project data | First project data load. | Inconsistency with the Project manager dates. |
| Step 2: Memberships updated | Start date has been changed for two memberships, one fixed a mistake, the other was a mistake. | Project manager dates consistent, other membership updated from 2006 to 2016. Two rows in the link table (the ones with the original start date) have been marked as Deleted in the state satellite. Soft Delete hides these from the view. |
| Step 3: Mistake corrected | The mistake made in the previous step was corrected (start date changed back). | Link row with wrong hash has been marked as Deleted, and the one marked in the previous step has been marked as re-Created. |
| Step 4: Project ends | The project and all memberships are closed. | Many end dates set, some wrong, some correct, some not set at all. |
