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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:00:27+00:00 2026-05-13T07:00:27+00:00

Im working on something incredibly unique….. a property listings website. ;) It displays a

  • 0

Im working on something incredibly unique….. a property listings website. 😉

It displays a list of properties. For each property a teaser image and some caption data is displayed. If the teaser image and caption takes a site visitors interest, they can click on it and get a full property profile. All very standard.

The customer wants to be able to allow property owners to add multiple teaser images and to be able to track which teaser images got the most click throughs. No worries there.

But they also want to allow the property owner to weight each teaser image to control when it is shown. So for 3 images with weightings of 2, 6, 2, the 2nd image would be shown 6/10 times. This needs to be balanced. If the first 6 times the 2nd image is shown, it cant be shown again until the 1st and 3rd images have be shown twice each.

So I need to both increment how often an image has been retrieved and also retrieve images in a balanced way. Forget about actual image handling, Im actually just talking about Urls.

Note incrementing how often it has been retrieved is a different animal to incrementing how often it has captured a click through.

So i can think of a few different ways to approach the problem using database triggers or maybe some LINQ2SQL, etc but it strikes me that someone out there will know of a solution that could be orders fo magnitude faster than what i might come up with.

My first rough idea is to have a schema like so:

TeaseImage(PropId, ImageId, ImageUrl, Weighting, RetrievedCount, PropTotalRetrievedCount)

and then

select ImageRanks.*
from (Select t.ImageID, 
             t.ImageUrl, 
             rank() over (partition by t.RetrievedCount order by sum(t.RetrievedCount) desc) as IMG_Rank 
       from TeaseImage t
     where t.RetrievedCount<t.Weighting
    group by t.PropID) ImageRanks
where ImageRanks.IMG_Rank <= 1

And then

 1. for each ImageId in the result set increment RetrievedCount by 1 and then
 2. for each PropId in ResultSet increment PropTotalRetrievedCount by 1 and then 
 3. for each PropId in ResultSet check if PropTotalRetrievedCount ==10 and if so reset it to PropTotalRetrievedCount = 0 and RetrievedCount=0 for each associated ImageId

Which frankly sounds awful 🙁

So any ideas?
Note: if I have to step out of the datalayer I’d be using C# / .Net. Thanks.

  • 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-13T07:00:27+00:00Added an answer on May 13, 2026 at 7:00 am

    If you want to do this entirely in your database, you could split your table in two:

    Image(ImageId, ImageUrl)
    TeaseImage(TeaseImageId, PropId, ImageId, DateLastAccessed)
    

    The TeaseImage table manages weightings by storing additional (redundant) copies of each property-image pair. So an image with a weight of six would get six records.

    Then the following query gives you the least-recently used record.

    select top 1 ti.TeaseImageId, i.ImageUrl
    from         TeaseImage ti
    join         Image i
    on           i.ImageId = ti.ImageId
    where        ti.PropId = @PropId
    order by     ti.DateLastAccessed
    

    Following the select, just update the record’s DateLastAccessed. (Or even update it as part of the select procedure, depending on how fault-tolerant you need to be.)

    Using this technique would give you fine-grained control over the order of image delivery, (by seeding their DateLastAccessed values appropriately) and you could easily modify the ratios if need be.

    Of course, as the table grows, the additional records would degrade query performance earlier than other approaches, but depending on the cost of the query relative to everything else that’s going on that may not be significant.

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

Sidebar

Related Questions

I'm currently doing something like this in some code I'm working on right now:
I have been trying to understand and get something working with dependency properties. I
Currently working on something which uses ajax for some pagination. What I'm looking to
I'm working on something that was built on a PC set-up using php and
I'm working on something that requires traversing through the file system and for any
I'm working on something that pulls in urls from delicious and then uses those
Working with TCL and I'd like to implement something like the Strategy Pattern .
I'm working on VS 2005 and something has gone wrong on my machine. Suddenly,
I am working with a set of data that looks something like the following.
Something really weird is going on with Xcode and an iPhone project I'm working

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.