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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:47:35+00:00 2026-05-30T19:47:35+00:00

There are many users, many groups that users can be part of. Each group

  • 0

There are many users, many groups that users can be part of. Each group has a resource quota.

The tables are as follows:

User: UserId, LastName, FirstName, ...
Group: GroupId, GroupName, ...
UserGroup: GroupId, UserId (Users are in Groups)
Resource: ResourceId, ResourceName, ...
GroupResource: GroupId, ResourceId, Quota (Users in Groups can access certain Resources specified Quota times)
UserResourceAccess: UserId, ResourceId, InsertDate, ...

Of course, there are daily and monthly quotas, but that doesn’t matter for the purpose of this question.

So, when user #1 (being in groups #1, #2 with resource quotas 2 and 1 respectively) accesses resource #1 his total quota for that resource should be reduced by 1: (1+2) – 1 = 2 (times left to access).

But then, there’s another user #2 who’s a member of group #2 and he tries to access the resource #1…

Here’s the interesting part, user #1 already accessed that resource and his total quota was reduced 1 time (which now equals 2) but we don’t know which group quota was reduced (or do we?)

So the question is, how to implement this logic in SQL Server 2005/2008 (maybe even Denali:)?

How can we know that user #2 can actually access that resource one remaining time and force user #1’s action reduce his group #1’s quota by 1 and not group #2′?

If it still makes any sense to you, please solve this problem. 🙂 I’ve been thinkin’ about it for quite some time now.

Just to make it clear, I want to have a single select statement that would tell me what user #2’s quota is right now, right after user #1 accessed that resource. (hint: it should still be 1 and not 0)

Update

User #1 has an aggregate quota of all the groups that he’s in, hence his quota for resource #1 is 2+1 = 3; and the user #2’s quota for resource #1 is 1 because he’s only a member of group #2 (which has a quota of 1). When someone from any of your groups (that have resource quota for resource being accessed) accesses a resource, your aggregate quota for that resource is reduced accordingly (by as many times as that resource was accessed).

Update 2

The quota reduction rule is as follows: a group with the most quota left should be used for each access. So, in the first example, when user #1 accesses the resource we choose group #1 because it’s got a quota of 2 (which is > than 1). And the next time, when user #2 accesses the resource we choose any group because they both have a quota of 1 access left. That’s the business rule that was missing.

  • 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-30T19:47:36+00:00Added an answer on May 30, 2026 at 7:47 pm

    I believe I understand what you are asking, but I believe you have a flaw in your logic. You are asking how to reduce available usage for a group, but in reality, you are calculating available resource availability from the user’s groups, and decrementing it for the user, not the group.

    If this is the case, you would aggregate your group resource availability, and subtract the user’s resource access counts.

    UPDATE

    Based on your last comment, I believe we’re getting on the same page. A group’s quota is fixed for all users in the group – if user #3 and user #4 are only in group #3, which has a quota of 2, user #3 could access twice, user #4 could access twice, or they could each access once.

    Given this, you are trying to calculate which group’s quota is used when a user in multiple groups accesses a resource.

    You are trying to determine the technical solution to an unwritten business rule – which group’s quota does a user pull from? You need to define that outside of the system first, and then implementing it is trivial. Which group should a user pull from? Is it based on number of users inside of the group? Does the group have a priority? Does the user have a preferred group? etc, etc.

    Until you know the business rule, any solution you put in place is untestable – you don’t have anything to compare it to.

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

Sidebar

Related Questions

I have many tables that represent groups that can be participated in (let's say
There are many techniques to enforce strong passwords on website: Requesting that passwords pass
There are many different styles of variable names that I've come across over the
There are many usability evaluation techniques that have been developed over the history of
I'm reading on Google App Engine groups many users ( Fig1 , Fig2 ,
I have a table containing roles. Many users can be assigned to a role.
I have a model class that has, among other things: class Group < ActiveRecord::Base
I've got a User model and Group model. User has_and_belongs_to_many :groups and Group has_and_belongs_to_many
I have a web app that lets users create groups. On the front page
I want to make user group system that imitates group policy in instant messengers.

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.