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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:42:32+00:00 2026-05-31T15:42:32+00:00

I am planning on using the following formula to calculate trending posts: Trending Score

  • 0

I am planning on using the following formula to calculate “trending” posts:

Trending Score = (p - 1) / (t + 2)^1.5

p = votes (points) from users.
t = time since submission in hours.

I am looking for advice on how to structure my database tables so that I can query for trending posts with DynamoDB (a nosql database service from Amazon).

DynamoDB requires a Primary Key for each item in a table. The Primary Key can consist of 2 parts: the Hash Attribute (string or number) and the Range Attribute (string or number). The Hash Attribute must be unique for each item and is required. The Range Attribute is optional, but if used DynamoDB will build a sorted range index on the Range Attribute.

The structure I had in mind goes as follows:

TableName: Users

HashAttribute:  user_id
RangeAttribute: NONE
OtherFields: first_name, last_name

TableName: Posts

HashAttribute:  post_id
RangeAttribute: NONE
OtherFields: user_id,title, content, points, categories[ ]

TableName: Categories

HashAttribute:  category_name
RangeAttribute: post_id
OtherFields: title, content, points

TableName: Counters

HashAttribute:  counter_name
RangeAttribute: NONE
OtherFields: counter_value

So here is an example of the types of requests I would make with the following table setup (example: user_id=100):

User Action 1:

User creates a new post and tags the post for 2 categories (baseball,soccer)

Query (1):

Check current value for the counter_name=’post_id’ and increment+1 and use the new post_id

Query (2): Insert the following into the Posts table:

post_id=value_from_query_1, user_id=100, title=user_generated, content=user_generated, points=0, categories=['baseball','soccer']

Query (3):

Insert the following into the Categories table:

category_name='baseball', post_id=value_from_query_1, title=user_generated, content=user_generated, points=0

Query (4):

Insert the following into the Categories table:

category_name='soccer', post_id=value_from_query_1, title=user_generated, content=user_generated, points=0

The end goal is to be able to conduct the following types of queries:

1. Query for trending posts

2. Query for posts in a certain category

3. Query for posts with the highest point values

Does anyone have any idea how I could structure my tables so that I could do a query for trending posts? Or is this something I give the up the ability to do by switching to DynamoDB?

  • 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-31T15:42:34+00:00Added an answer on May 31, 2026 at 3:42 pm

    I’m starting with a note on your comment with the timestamp vs post_id.
    Since you are going to use DynamoDB as your post_id generator, there is a scalability issue right there.
    Those numbers are inherently unscalable and you better off using a date object.
    If you need to create posts in a crazy speed time you can start reading about how twitter are doing it
    http://blog.twitter.com/2010/announcing-snowflake

    Now let’s get back to your trending check:
    I believe your scenario is misusing DynamoDB.
    Let’s say you have one HOT category that has most posts in it.
    Basically you will have to scan the whole posts (since the data isn’t spread well) and for each start to look at the points and do the comparisons in your server. This will just not work or will be very expensive since each time you will probably use all your reserved read units capacity.

    The DynamoDB approach for those type of trends checking is using MapReduce
    Read here how to implement those: http://aws.typepad.com/aws/2012/01/aws-howto-using-amazon-elastic-mapreduce-with-dynamodb.html

    I can’t specify a time, but I believe you will find this approach scalable – though you won’t be able to use it often.

    On another note – you could keep a list of the “top 10/100” trendy questions
    and you update them in “real-time” when a post is upvoted – you get the list, check if it needs to be updated with the newly upvoted question and save it back to the db if needed.

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

Sidebar

Related Questions

Following advice , I'm planning to log errors from several time critical python processes
Backed up a database from my hosting account. Using the following script to restore.
I'm planning to develop a Web/cloud application using python which does the following, 1.
I have the following scenario where I’m planning in using windows authentication. 1.1) I
I'm planning on using VBO in order to display a large points array, around
I am planning on using the following social networking elements on my website: Facebook
Background: I'm planning on using the JW FLV Media Player for streaming some videos:
I'm planning on using Apache NMS for ActiveMQ messaging, and am wondering what serialization
Soon I'll be launching my new site and i was planning on using gmail
Planning to create a new website for our product using ASP.NET MVC 4. Site

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.