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 4566714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:49:40+00:00 2026-05-21T18:49:40+00:00

I have a problem in which I need to track actual sales against a

  • 0

I have a problem in which I need to track actual sales against a sales goal for a “Period”. A Period can be a day, month, quarter or year.

Initially, I have come up with an enum for PeriodType (1-4, Day, Month, Quarter, Year respectively). Given this, I would need 3 values to uniquely describe a Period: 1) a PeriodType, 2) an integer for a PeriodYear (eg. 2010, 2011, etc.) and 3) an integer for a PeriodNumber.

So, for instance, {1,2011,38} would be the day February 2, 2011. Or, {3,2,2010} would be the second quarter of 2010. Or {2,4,2012} would be the month of April, 2012.

Having an object that exposes these three properties is not a problem. But in terms of the database, I am trying to figure out how to store the relationship of an entity (like a Goal or a Sale) to a Period – it doesn’t seem very elegant to have 3 columns in every table that requires a Period relationship. One way would be to have a table for Period that has a primary key and the other 3 values – but it doesn’t make sense to persist the Period itself like that because it is a time concept that can be calculated.

What would be the best way to represent my definition of a “Period” with a single unique value? Or is my definition of a Period misguided and there is a simpler way to do the same thing?

  • 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-21T18:49:40+00:00Added an answer on May 21, 2026 at 6:49 pm

    The simplest solution would be to store Sales against the lowest level of granularity, i.e. a day. In would then be a simple matter to aggregate those sales for goals which track sales at a longer period.

    If this does not meet your requirements you should explain in a bit more detail how the data is gathered and used, with a specific focus on why you need a more complicated data structure.


    The question of timezones is problematic but not a showstopper. The important thing is to agree on a single point of truth for time, which ought to be the database, and hold all date times in UTC. Clients would have to translate UTC into their timezone when retrieving data and vice versa when saving it.

    How easy this is in practice depends very much on your flavour of database, but pretty much every RDBMS ought to support this functionality.

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

Sidebar

Related Questions

I have a problem to test my non activity-class which need the context of
I faced an interesting problem today. I have 4 strings which I need to
I have a problem which i can't seem to find the solution to. I
I have a small problem which i can't seem to figure out. I tried
I have a problem which I don't really know how to solve. I have
I have a problem which makes me crazy. I think it is very easy
I have a problem which requires a reversable 1:1 mapping of keys to values.
I have a problem which I cant seem to find answer to through searches
I have a problem which I don't know how to fix. It has to
I'm developing an Eclipse plug-in and I have a problem which is reproduced here:

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.