views:

656

answers:

2
A: 

Your Activities class is just a way to collect together different types of activities. To keep it from polluting the rest of your schema, I would separate it from your other classes. That will free your mind to focus on Projects, Tasks, and Reports on their own merit within the schema structure.

Once you figure that out, you can go back and add your activities class. Call it a "cross-cutting" concern if you want. It would look something like this at the table level:

Table:  Activities
Fields:    ActivityID       PK Int Identity
           ActivityType     Int  <-- tells you the originating table
           OriginatingID    Int  <-- from the PK of the originating table
           Description      ..etc.

Time tracking has its own table/class.

You may be wondering, how do I draw lines between my Activities class and my other classes in the designer. You don't. You can do ad-hoc joins to your other tables/classes as needed using Linq.

If you are using a repository pattern, you can include code in your repository that adds or updates the records in the Activities class automatically, when a caller updates a Project, Task, Report, etc.

Robert Harvey
I thought I had to use the Activity class so that Task and Project have something to inherit from and there is a relevant discriminator property in the Activities table which Task and Project use via their parent class? Also I dont understand how the above will help with linking task to project and project to activity?? is there a way I can show inherited properties in the project class so that the activityID in the Project class can be used to associate it with a Task projectId??
Pricey
I am used to thinking about these things at the table level. I understand the desire to have a relevant discriminator property, since an Activity can be anything. You link task to project by having a ProjectID in the Task. Activities are already linked to the Project by the OriginatingID <-- ProjectID.
Robert Harvey
A: 

I came up with a solution to this using the entity diagram for LINQ to SQL as shown above.

Where I created a base activity abstract class that activity, task, project and project activity inherit from.

Also the entity diagram seems to require you to add properties to inherited classes just to be able to use them for associations between classes. So in the end I did just that and made the original activityId from the base activity class a private property.

Pricey