Git Product home page Git Product logo

assessment_tssql's Introduction

schema design implementation (bonus)

  • subscriptions

NOTE: I have implemented a subscription table and used it in my solution

  • orders

it could be something like:

export const orders = sqliteTable("orders", {
  id: integer("id").primaryKey().notNull(),
  order_date: timestamp("order_date").notNull(),
  plan_id: integer("plan_id").notNull(),
  status: text("status").checkIn(["new", "paid", "canceled"]).notNull(),
  customer_id: integer("customer_id").notNull(),
  payment_code: text("payment_code").notNull(),
  cost: integer("cost").notNull(),
  notes: text("notes"),
  serial_number: text("serial_number").notNull(),
});
  • subscriptionActivations
export const subscriptionActivations = sqliteTable("subscription_activations", {
  id: integer("id").primaryKey().notNull(),
  activationCode: text("activation_code").notNull(),
  userId: integer("user_id")
    .notNull()
    .references(() => users.id, { onDelete: "restrict", onUpdate: "restrict" }),
  subscriptionId: integer("subscription_id")
    .notNull()
    .references(() => subscriptions.id, { onDelete: "restrict", onUpdate: "restrict" }),
  activationDate: timestamp("activation_date").notNull(),
});

question (bonus)

If you were to introduce two more props to plans:

  1. defaultUsers: number of users included in the plan by default
  2. pricePerUser: price per additional user beyond the default

How would this affect the current plan upgrade calculation?

ANSWER: if a user upgraded and he exists in the 'defaultUsers' of a plan we should remove him. also -possibly- when calculating the cost of upgrade we should consider 'pricePerUser' instead of normal price

assessment_tssql's People

Contributors

alhessan avatar

Watchers

 avatar

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.