From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Creating sales and transaction table in database

Creating sales and transaction table in database

Now, we have completed the payment process. Once the payment is made, now we need to make sure that the related products stock is updated and along with that, we also need to maintain a record of all the sales and transactions happening. So, now we will first create the sales master table, where all the transactions are stored, and then we will make an API to update the stock and sales master table along with the sales transaction table. And finally, we will call this API when the payment is complete. Now let's understand what sales master and sales transaction table will actually store. Let's say the user purchases one denim jacket and three jeans. Then in the sales transaction, there will be two records added, the denim jacket with quantity one, and the second record will be jeans with quantity three. And then in the sales master, only one record will be added, which will have the buyer ID, which relates to the buyer master, the total amount and other payment details. And each sales…

Contents