Code Monkey home page Code Monkey logo

autostocklist's People

Contributors

ivancea avatar

Watchers

 avatar

autostocklist's Issues

Database: Transactional stock management

Instead of calculating the stock from the loss/resupply tables:

  • Save the stock in the item table
  • For a loss/resupply:
    • Open a transaction
    • Modify stock (a CHECK constraint would keep it positive)
    • Insert/Update the loss/resupply table (a CHECK constraint would kep them positive too)
    • If any of those fails, ROLLBACK and report
    • If both work, COMMIT

Database model

Final

User -> Stock list -> Item -> Stock movement

User {
   /* Auth, basic information */
}

Stock list {
    name.
    default?
    /* Future: buying and analytics configurations */
}

Item {
    name,
    minStock,
    maxStock,
    actualStock
    /* Future: buying and analytics configurations, price (for spending analysis) */
}

Stock loss{
    date,
    quantity (representing a stock reduction)
}

Stock resupply{
    date,
    quantity (representing a stock increase)
}

Stock total (VIEW) {
    itemId,
    stock
}

MVP

  • No users
  • No multiple lists

ScyllaDB + <another relational DB for users an configs> vs PostgreSQL

For a PK of (user, item, date), it'll generate around 365 light entries per user/item, in the worse case of all items consumed every day.
For an average of 50 items per user (big shopping list), it'll go around 15.000 entries per year per user.

15.000 entries per user, knowing that a RDBMS is required for the users, items and configurations management, using ScyllaDB may be an overkill, and a development obstacle as it has a slower startup and worse tools to interact with.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.