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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:13:37+00:00 2026-06-15T05:13:37+00:00

My document structure in CouchDB looks like below: { _id: 0a68cdbe4a7f3abf4046bc, _rev: 1-1508, score:

  • 0

My document structure in CouchDB looks like below:

{
 "_id": "0a68cdbe4a7f3abf4046bc",
 "_rev": "1-1508",
 "score": {"math":90, "physics": 88, "chemistry": 60},
 "student_name": "Mike"
}

I need to show below stats in the front end to setup a student’s profile:

  • Given a student _id, how can I retrieve that student’s rank in each course;
  • Given a student _id, how can I retrieve that student’s rank for his total score (math+physics+chemistry).

Suppose I have only 2 students, the 2nd student’s record is like below:

{
 "_id": "0a68cdbe2344a3abf4046bc",
 "_rev": "1-1608",
 "score": {"math":80, "physics": 98, "chemistry": 90},
 "student_name": "Jane"
}

So Mike’s rank should be:

math: 1
physics: 2
chemistry: 2
total: 2

and Jane’s rank should be

math: 2
physics: 1
chemistry: 1
total: 1

Let me know if I did not state the problem clearly.

I did not figure out the way to create views to get the rank. What I have tried:

  • create views that map score to student info. Then I can query a score range to get students that their score is in that range.

Edit: the functionality of query by user name and retrieval of rank does not need to be implemented by a view only. Any idea is welcomed!

Edit2: The number of courses would be 1K to 3K. The number of students would be 1M to 2M.

  • 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-15T05:13:40+00:00Added an answer on June 15, 2026 at 5:13 am

    I have an idea that’s based on @joscas’s answer.
    You can create a view like this:

    key         -> value
    ---------------------
    ("math", 0) -> 2
    ("math", 1) -> 3
    ("math", 2) -> 5
    ....
    ("math", 100) -> 50
    

    I made the assumption that the score range for each course is from 0 to 100. The idea is that:

    • For each course, you aggregate the number of students whose score falls in that score bucket (your have 101 buckets for each course, namely from bucket0 to bucket100).
    • Then you either use a chained view like @joscas pointed out, or use another external program to get a cumulative distribution of the score histograms like below.

    key         -> accumulative value
    ------------------------------------
    ("math", 0) -> 2
    ("math", 1) -> 5
    ("math", 2) -> 10
    ....
    ("math", 99) -> 32324
    ("math", 100)-> 32374
    

    Given a course name c and your score s, this second view tells you how many students play not as good as you in this course, from which you can derive the rank by using n-#s, where n is the total student number enrolled in c, #s is the number of students who get lower score than s. For instance, a query of "math", 99 will return 32374-32324 = 50 which is the rank of the student who got 99 in “math”.

    For the total score part of your questions, you can use the similar idea but change the bucket size and number.

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

Sidebar

Related Questions

I have a schema, with a document structure that looks like this: { _id
i have a structure of document in mongodb as below { _id: some_id, key1:
I have a index document structure like below; { term:some term, inlang:some lang translations
I have a document structure like this: { _id: ..., name: ..., keywords: {
I have a document structure in Solr that looks something like this (irrelevant fields
My table structure is below: CREATE TABLE [ACC].[Document]( [DocumentID] [int] IDENTITY(1,1) NOT NULL, [Date]
I'm working with an XML document that contains a structure that looks similar to
If I have a table structure like this: Transaction [TransID, ...] Document [DocID, TransID,
I have the following document structure: { _id : 20120725/foobar/song/test-pg3-long-title-here-test-lorem-ipsum-dolor-lo, live_daily_count : 4, metacontent
I have the following document structure inside a mongodb collection: { _id: XXX, Name:

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.