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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:55:03+00:00 2026-05-25T12:55:03+00:00

I am working on a small web application that allows users to trade credit

  • 0

I am working on a small web application that allows users to trade credit to each other. I would like to have your comments on my initial design (efficiency, flexibility, security etc.)

In particular, a typical transaction happens as follow:

User A can offer to do a job in exchange for X credits. Users B and C can accept the offer. A total of X credits will be subtracted from B and C’s accounts. When the job is completed, X credits will be added to A’s account. A can use earned credits to trade with other users.

I am thinking of a database with 3 tables: Job, Transaction and Account. Account table will keep track of credit earned and spent for each user.

Each time a job is done for user B and C by user A:

  • Two transactions are recorded in Transaction table: a transfer from B to A, and a transfer from C to A

  • Account table will be updated: available credits will be updated in A, B and C’s accounts

  • Job table is also updated.

(All these actions will be wrapped in an SQL “transaction”, i.e., all records are updated, or none)

When a transaction is reverted (say, between A and B, but not between A and C), A and B’s Account and Account_History will be updated, transaction between A and B will be set to “revert”.

A sketch in Rails goes as follow:

  • class Job

    attributes: :job_id, :total_credit,:created_at, :updated_at

    belongs_to :seller, :class_name => “User” belong_to :buyers,
    :class_name => “User” # one job may be done for multiple users

  • class Transaction

    attributes: transaction_id, :buyer_id, :seller_id, :status,
    :credit, :created_at, :updated_at

    belongs_to :seller, :class_name => “User” belongs_to :buyer,
    :class_name => “User # one transaction record per credit swap
    belongs_to :account

  • class Account

    attributes: :account_id, :user_id, :available_credit

    belongs_to: user

I am not sure if I should:

  1. Create Account_History table to present summary statistics extracted
    from Account table (such as last month transactions, total credit
    earned/spent etc.) to customers, or to store these info in a series
    of cached queries.

    Represent a pending transaction (i.e., when B accepts A’s offer but
    the job is not done yet) and a completed transaction (i.e., when B
    accepts A’s job) in separated records in Transaction table. The
    other option would be just to change status of a transaction from
    pending to completed.

Thanks for your comments.

  • 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-25T12:55:04+00:00Added an answer on May 25, 2026 at 12:55 pm

    A more conventional approach would be to use more of a double-entry accounting design.

    You can read about this design just about anywhere, but here is a link to a pretty good discussion of what it is and how it works.

    The upshot for your design would be that you want a separate table to tie the two pieces of your example transaction into a single unit of work. You want one table that has a single entry per business transaction and another table that one entry for each account involved in that transaction. In the referenced link, these are the JOURNAL and POSTING tables.

    In this kind of design, the available credits are not stored in the account, unless you want to do so as a denormalization. Typically the balance is always calculated.

    You could decide to have an account balance history table for reporting purposes, but you will need to be sure to handle recalculating this history if your system allows for old transactions to be edited (which it wouldn’t, if it were a conventional accounting system).

    If you want to differentiate between transactions that are pending versus those that have been completed, then you can put a status flag on the transaction (in the referenced link, the JOURNAL table). However, there is also a more full-blown accounting convention that would give each user two accounts, one of earned credits and one of unearned credits. In this scheme, using your example, B and C would put some credits into A’s pending credit account. This would create draws on B’s and C’s accounts right away, so that they don’t spend those credits elsewhere. When A completes the job, those credits get moved from A’s pending account to A’s current account. If the job gets cancelled, you’d put in a transaction to transfer back from A’s pending account to B’s and C’s current accounts.

    This way may seem a bit more complicated, but it has the distinct advantage of there always being a record of everything that has happened.

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

Sidebar

Related Questions

I have a small web.py Python application that I would like to serve under
I'm working on a small web application that will let users enter calendar events.
I’m currently working on a small web app that allows people to search for
I'm working on a small C#/WPF application that interfaces with a web service implemented
I'm working on web application which, among other things, needs to save small file
I am working on small web application for iPad Safari. I have to display
I'm working on a Python web application in which I have some small modules
I'm working with this small web application (1 page) built by someone else that
I am working on an application that allows users to dynamically add questions to
I'm working on a small web application that changes the contents of a select

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.