Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 290673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:01:09+00:00 2026-05-12T06:01:09+00:00

The focus of this question is primarily to develop a relational db scheme given

  • 0

The focus of this question is primarily to develop a relational db scheme given the object model here.

This part of the system is concerned with time based allocations made by Resources (different flavors of Employees & Contractors) to Activities (either a Project or an Account). Data entry is weekly, and the domain model must validate the weekly entries (~ 5 per resource with 200 resources) before letting them be persisted. Queries from the db must support approval / analysis of Allocations both by activity(ies) and resource(s).

I am already using NHib (& FNH) in simpler parts of the system, so ancillary to my primary focus is to flesh out other concessions the domain model must make for the sake of persistence with these tools. For example:
1) properties that would otherwise not be virtual are virtual
2) id generation (Entity as a base class is automapped to generate an ID (int)

Here are domain classes of interest, which are tested for presentation purposes:

 public class Allocation : Entity {
    public virtual ResourceBase Resource { get; private set; }
    public virtual ActivityBase Activity { get; private set; }
  public virtual TimeQuantity TimeSpent { get  private set; }
}

public abstract class AllocatableBase : Entity {
    protected readonly IDictionary<DateTime, Allocation> _allocations = new SortedList<DateTime, Allocation>();

    public virtual IEnumerable<Allocation> Allocations { get { return _allocations.Values; } }

}

public abstract class ResourceBase : AllocatableBase {
    public virtual  string Name { get; protected set; }
    public virtual  string BusinessId { get; protected set; }
    public virtual  string OrganizationName { get; protected set; }
}

// example of a concrete ResourceBase
public sealed class StaffMemberResource : ResourceBase  {
    public StaffMember StaffMember { get; private set; }

    public StaffMemberResource(StaffMember staffMember)
    {
        Check.RequireNotNull<StaffMember>(staffMember);
        UniqueId = GetType().Name + " " + staffMember.Number; // bad smell here
        Name = staffMember.Name.ToString();
        BusinessId = staffMember.Number;
        OrganizationName = staffMember.Department.Name;
        StaffMember = staffMember;
    }
}


public abstract class ActivityBase : AllocatableBase {

    public virtual void ClockIn(DateTime eventDate, ResourceBase resource, TimeQuantity timeSpent) {
        ... add to the set of allocations if valid
    }

    public virtual string Description { get; protected set; }
    public virtual string BusinessId { get; protected set; }
}

// example of a concrete ActivityBase
public sealed class ProjectActivity : ActivityBase {
    public Project Project { get; private set; }

    public ProjectActivity(Project project) {
        Check.RequireNotNull<Project>(project);
        Description = project.Description;
        BusinessId = project.Code.ToString();
        UniqueId = GetType().Name + " " + BusinessId;
        Project = project;
    }
}

Here is the initial db structure I’m throwing out, looking for feedback here:

table Allocations (
   AllocationID INT IDENTITY NOT NULL,
   StartTime DATETIME NOT NULL,
   EndTime DATETIME NOT NULL,
   primary key (AllocationID)

      foreign key (ActivityID) 
      foreign key (ResourceID) 

)

table Activities (
   ActivityID INT IDENTITY NOT NULL,
   primary key (ActivityID)

   ActivityType NVARCHAR(50) NOT NULL,

      foreign key (WrappedActivityID) // for lack of a better name right now

)

table Projects (    // example of a WrappedActivity
    ProjectID INT IDENTITY NOT NULL,
   Prefix NVARCHAR(50) null,
   Midfix NVARCHAR(50) null,
   Sequence NVARCHAR(50) null,
   Description NVARCHAR(50) null,
   primary key (ProjectID)
)

table Resources (
   ResourceID INT IDENTITY NOT NULL,
   primary key (ResourceID)

   ResourceType NVARCHAR(50) NOT NULL,

      foreign key (WrappedResourceID) 

)

table FullTimeStaffMembers (  // example of a WrappedResource
    StaffMemberID INT IDENTITY NOT NULL,
   Number NVARCHAR(50) not null unique,
   FirstName NVARCHAR(50) not null,
   LastName NVARCHAR(50) not null,
   DepartmentID INT not null,
   primary key (StaffMemberID)
)

I’m not shooting for a specific inheritance mapping scheme just yet (ie, table per class, etc) as much as looking to get a starting db model that works (even if not optimally performance wise). I’m already painfully aware that db skills make my programming skills look awesome by comparison, so all constructive feedback & questions welcome!

Cheers,
Berryl

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:01:10+00:00Added an answer on May 12, 2026 at 6:01 am

    I am confused by your table structure. You mention foreign keys, but you don’t say what table the foreign key references. In most cases, I can infer the table based on your naming conventions. If you create the tables using SQL, you will do well to make the references explicit as to table. In most cases, you will also do well to enforce referential integrity in the schema.

    But I don’t understand the connection between WrappedResourceID and ProjectID. I’m guessing that the following design pattern will help you to model different kinds of activity that all have some common attributes, but also have attributes peculiar to the type of activity.

    Do a web search on “generalization specialization relational model”. You’ll get some good articles describing this pattern. It’s a pattern that is generally not taught in beginning db design courses, but people accustomed to inheritance need to know it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[This question is in relation to this question ] Setting : I have this
I have seen this question: How to keep WPF TextBox selection when not focused?
The discussion in this question is the direct cause for me asking this question.
I've learnt Cocoa + Objective C primarily for iPhone development, and I need to
This is the page, its a wordpress powered site: http://bit.ly/9oJXWV You select some value,
What is the best open source document control app for PHP/MySQL? Focus is to
I am outputting content from my models to my templates, however some model fields
Don't be afraid to use any technical jargon or low-level explanations for things, please.
We're planning to build a web application that needs to be highly secure because
In the D2 programming language, what are the performance implications of using exception handling?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.