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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:47:36+00:00 2026-06-14T15:47:36+00:00

We are developing advertisement scheduling system. Now, we want to calculate prize details for

  • 0

We are developing advertisement scheduling system. Now, we want to calculate prize details for that. Right now, database is like, we have 2 tables city and daypart. city contains 30+ million records, and daypart contains 6 records like 6am to 10pm.etc. Now we want to calculate prize for advertisement. i.e if any user has given advertise to Mumbai city for 3 dayparts then how to calculate prize for that. One way is that create one more table and in that kept all the combinations of city and daypart and its prize. but then this table contains 60+ millions records, and if new daypart is added then we have to update this table again which is more problematic.
ex. city contains 1 record and daypart contains 6 records, then new table contains total 6 records and its prize.
is there any other way to calculate prize for above scenario?

  • 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-06-14T15:47:37+00:00Added an answer on June 14, 2026 at 3:47 pm

    As you’ve mentioned, prize amounts can differ based on city or daypart, and it doesn’t sound like there’s any standard algorithm or calculation to calculate a prize based on city and daypart (prize amount seems proprietary information to your system) – so some sort of lookup table would probably be your best bet.

    I’d imagine your table columns would look something like this:

    Countries: id (integer, non-null), countryName
    Cities:    id (integer, non-null), cityName,   countryId
    Prizes:    cityId, startHour, amountPerHour
    

    Some notes:

    • City and Country are split into multiple tables based on your information of 30+ million city records.
    • Rather than store ‘dayparts’ as a time range (3pm-6pm), store it in the lookup table as a price per hour that starts at a specific time. For example:

      • If CityA (id=1) costs $15 for 6am-9am, and $30 for 9am-12pm, (and 0 otherwise, for simplicity) then this table would contain these entries:

        cityId    startHour    amountPerHour
         1         0            0
         1         6            5
         1         9            10
         1         12           0
        
      • This gives you the flexibility to easily add new dayparts (one of your concerns), or even have different dayparts per city. StartHour would represent the startHour within the day (0-23), and could even be a decimal value if necessary (12.5 for 12:30pm).
      • Calculation for a time range just becomes a matter of figuring out how many startHours are within your range, then doing some basic math with amountPerHour.

    If this doesn’t meet your needs, another alternative (as you mentioned) is just a straight-up lookup table, in which case you’d have a table of dayparts, and prizes table would become cityId | daypartId | amount.

    The size of your tables isn’t that bad if you’re worried about performance – especially if you properly use your primary key columns and have table indexes.

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

Sidebar

Related Questions

Developing a network application, I have a Connection class that manages sending and receiving
right now I am developing an application and it has some set of images
Developing an application for Android, i want to record data that will be usefull
Developing an MVC application, i now need to have test other browser versions. Installed
i am developing an application which have eight advertisement boxes, the advertisement data with
Developing Java, you have always learned that its best to create an ArrayList by
Developing for Android 2.3, I have a question regarding layouts. I use a vertival
Developing a project of mine I realize I have a need for some level
Iam developing one application.In that iam placing the radio buttons(uiimageview) on table view and
While developing an application using gwt in ecliplse crashed. Now the server is running

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.