Online Retail Management System

Online Retail Management System

·

14 min read

This report describes in detail every phase of designing and implementing a database system for an online retail store and includes several SQL queries to show its functionality. This is a group project I did back when I was in school. To upload this document to hashnode, however, I removed their contributions and left mine for viewing purposes:

TABLE OF CONTENTS

1. Summary 4

2. Project Statement: 4

2.1 Overall Goals of the System 4

2.2 Context and Importance of the System 4

2.3 Scope of the Project 5

2.3.1 IN-Scope 5

2.3.2 Out-Scope 5

2.4 Related systems and any open-source tools 5

3. Requirements: 6

3.1 Data Requirements 6

3.2 Business Rules and Logic 6

3.3 Sample Output 7

3.4 Other Assumptions 7

4. Conceptual Design 8

4.1 ERD 8

4.2 Explanations 9

5. Translating ERD 10

5.1 Relational Schema 10

5.2 Referential Integrity 12

7. Database Implementation – Create Commands 16

8. Data 22

8.1 Insertion Commands 22

8.2 Select Commands 29

9.4 Queries by Trim Kerwin 41

10.4 Queries by Trim Kerwin 51

11. Summary 55

11.4 Summary by Trim Kerwin 56

11. Appendix – Division of work 57

References 57

1. Summary

In this project, we developed and implemented a database system for an online retail store. We focused on products related to sports, such as Top (e.g., T-shirts), Bottoms (e.g., tights) and shoes (e.g., running shoes), but it can easily be modified to include other types of products. The first phase was writing all of the requirements and translating them into an Entity Relationship Diagram (ERD) model. Next, we converted the conceptual model into a relational schema as well as a data dictionary to define the datatypes of each attribute. Based on this step, we implemented the database by writing SQL create commands, and inserted data using insert commands. Here, we found a few flaws in our initial design as well as in several datatypes' declarations. Every error we encountered was solved by going back to the previous steps and modifying the design. Finally, we tested the database by querying, deleting, and updating the database. All those steps are outlined in this paper.

2. Project Statement:

2.1 Overall Goals of the System

In recent years, retail stores have found value in selling their products online through an e-commerce platform, such as Amazon, or by developing a website. The rise in online retail stores inspired our project that focuses on an online retail management system. We aim to develop an efficient system that allows storing and manipulating current inventory, filtering products according to users’ needs, managing customers, which is an integral part of a business, and storing cart items for every customer to better experience shopping online. These details will allow us to create a successful online retail business with scalability and necessary features for future growth.

We would like to take advantage of the rapidly growing online shopping in order to increase our customer base. Each customer has a first name, last name, email address and shipping address which must be valid in order to purchase products. A customer may create an order that contains multiple products. Payment must be either a credit card or a debit card since it is an online shopping experience. There are different types of products that we sell: shoes, tops (e.g., shirts) and bottoms (e.g., pants). Each product has a name, quantity, price per unit, description, color, section (e.g., men) and category (e.g. basketball). A customer can also add products to the cart and create an order whenever they would like to. However, products might be sold out, so the customer will be notified if one or more products in the cart are no longer available.

2.2 Context and Importance of the System

According to the most recent statistical data published by the United States Census Bureau, sales from e-commerce for U.S. retailers rose 14.3% from $506.1 billion in 2018 to $578.5 billion in 2019. The data also shows an increase of 3% in the total sales between 2018 and 2019 [1]. Online shopping has likely increased because it is a convenient way to shop. One can immediately go through many products by utilizing filtering features. Online shopping allows the customers to save time; not only does it save time looking for a specific product, but it also saves the time that the customer would have spent on the road driving to a physical store.

With the recent shift in shopping ideology, partially impacted by the pandemic, the world is at an all-time high for ordering all necessary goods remotely or through the internet; the same applies to clothing and attire items. The online sales industry has become a competitive market and will not cease to operate. Over the coming years, there is nothing, but exceptional growth projected for this market.

2.3 Scope of the Project

2.3.1 IN-Scope

  1. Customers

  2. Product (Shoes, tops, bottoms)

  3. Order

  4. LineItem

  5. Cart

  6. Payment

  7. Shipping

  8. Returns

2.3.2 Out-Scope

  1. Membership

  2. Gift cards

  3. Customer service requests

  4. Alternative types of payment (Cash,Cheque,Cryptocurrency,etc)

  5. Exchange of items (trading an item for another item)

  6. Insurance/liability for items that may be damaged or lost.

  7. Insurance/liability for payment methods malfunctioning.

  8. Vouchers for returned items.

  9. Multiple Language Settings.

  10. Social Media.

  11. Security(verification/MFA)

  12. Webpage compatibility/mobile webpage.

  13. Images correlated with product

3. Requirements:

3.1 Data Requirements

  • Each customer has a customer ID, first name, middle name, last name, cellphone number, email, and shipping address (including street, city, state, and zip).

  • A customer can save zero or more products in a cart, for each product must specify the amount. Each product can be saved in zero or more carts.

  • An Order has order ID, total price, tax, date, time. Every order can have one or more items and one customer. Each customer can have zero or more orders. Every order also has one payment method, and every payment has one order.

  • Payment has payment ID, total, type (debit, credit, etc.), credit card 4 digits, credit card company (VISA, AMEX, etc.).

  • Every product has product ID, name, description, quantity, unit price, section (Men, Women, Kids), color, collection, and category (basketball, football, baseball, etc.). Every product can appear one or more in an order, and every order has one or more products.

  • Shoe is a product. Every pair of shoes has US size, EU size.

  • Top (e.g. shirts, jackets, etc.) is a product. Each top has fit type (regular, tall, athletic), size (S, M, L), type (t-shirt, jacket, sleeveless), and material (Cotton, polyester).

  • Bottom (e.g., pants, shorts, sweatpants, etc.) is a product. Each bottom has fit type (compression, regular), size (S, M,L) and material (Cotton, polyester).

  • A product must belong to one of the following: shoes, tops, bottoms.

  • Every order can be shipped in one or more shipments, but every shipment must be associated with one order. Shipment includes tracking number and address.

  • Items can be returned by a customer. There could be one or more items that are returned by exactly one customer.

3.2 Business Rules and Logic

  • Tax percentage will be fixed based on the location of the warehouse.

  • When a customer creates an order, an email will be sent to the customer with the receipt.

  • Accepted payments are limited to either credit cards or debit cards.

  • Payment information includes 4 digits and company name. The ID will be generated based on both (first digit is for company and 4 other digits are the card’s last digits)

  • Generation of Customer ID – Holds personal information of customer. Auto-generates prefix and number of characters in the ID

  • Generation of Order ID - Holds information of the order (price before and after tax, the tax, time, date). Auto-generates a reference number of the sale.

  • Each order must be created by one customer.

  • Each customer must have a valid address for shipping the products. If the address is not valid, the customer cannot create an order.

  • If a product’s quantity in the inventory is low, an email will be sent to all customers that have this product in their cart to notify them that it might be sold out soon.

  • Each order can have only one method of payment

  • Transaction Triggers - May be suspicious in nature. Transactions over a certain amount could require an inquiry from a representative. Transactions that have an international address or address other than the one found in the customer ID may be denied.

3.3 Sample Output

  • Output of computerized bills/ receipts– After every transaction the system will produce a bill/ receipt to verify proof of purchase and so that customers also have proof for returns. This will act as confirmation of purchase and ensure the monetary transaction information is correct.

  • Output of Stock and Inventory List – The system at the end of each day will produce a stock list for the store manager to review so they can cross check invoice after the day against what was sold. This will allow for accurate inventory listing and will further help avoid any confusion pertaining to product storage.

  • Customer distribution among states. The system will count the customers in each state and create a report. This might be helpful for marketing strategy.

  • List of the items that were sold every day. This report might indicate which items are more popular than others and can be helpful in inventory management. This can also assist with creating a daily or weekly inventory listing to help keep track of inventory management with reference to items being high in stock, low in stock, or out of stock.

  • Output of items sold. This can assist the business in finding the most popular products and then further breaking down product popularity with reference to the region or location of the customers. This can allow marketing to utilize a specialized strategy with reference to advertising based on location.

  • Output of revenue per location. This can be broken down by state, city, or zip code. It will allow the business to understand where the most revenue is being generated and further allow for marketing strategies to target these areas.

  • Output of returning customer information. Displaying and gathering statistics about returning customers or lack thereof will allow the business to understand the strongest customer base by location. This could be a way of rewarding customers (if we decide to do discounts).

3.4 Other Assumptions

  • Our system will be able to handle a huge volume of data since this will be used in stores at several different locations and an online store

  • Our system will help us to retrieve data quickly so that we can analyze trends and make predictions for our business

  • Our site will appear in related search engine searches.

  • Our customer base will be productive and make multiple transactions over time.

  • Our products will be at the top of the line and attractive for customers

4. Conceptual Design

4.1 ERD

4.2 Explanations

Payment: The payment entity is the first entity in the ER diagram. Its primary key is payment ID, and it has three attributes: Payment type, Payment digit and Payment company. It has a binary relationship with the Order entity where each order has one payment listed and each payment is associated with one order.

Order: The Order entity is next in line in the ER diagram. Its primary key is Order ID, and it has three attributes: Order Subtotal, Order Tax and Order Total. It has a binary relationship with Payment, Line Item, Customer, Shipment and Product. For Payment, Order has a relationship where every order has a payment, and every payment is associated with an order. For Line Item, every order can contain one or more line item and a line item can be associated with one order. With Customer, Customers can create one or more orders and an order will have one customer.

Customer: In our customer entity our PK is customer ID, and the attributes are customer First Name, customer Middle Name, customer Last Name, customer Phone, customer Email, customer Address, street, city, state and zip. Customer has a binary relationship with Order. Customer’s relationship with Order is that a customer can create one or more orders and an order will have one customer.

Line Item: has a PPK that is line number. Line item is a weak entity because it is dependent on Order. It has three attributes: quantity, unit price and total which is a derived attribute. Line item has a binary relationship with Order and Product. With an Order, it can contain one or more line item and one line item can be associated with one order. In the case of Product, a product can have zero or many line items and each line item must be associated with one product.

Cart: The cart is a result of the relationship between the customer and the product. Due to this many to many relationship, the cart will be give n the primary key of both of these entities. The cart will also be responsible for maintaining the quantity of total items within itself, and will be attributed other derived attributes such as cartSubtotal, cartTax, itemsCount, and cartTotal.

Shipment: The primary key is composed of both orderID and TrackingNo. The address is also recorded for every shipment. There could be one or more shipments for each order, so there is a one-to-many relationship between shipment and LineItem.

Returns: Due to the many to many relationship that is formed between the order and product entities, the returns table is created. The returns table will be given the primary keys of both of the strong entities. It will also be attributed the quantity of items to be returned, the date of the return, and derived attributes such as itemsCount and totalRefund.

Product: has a primary key represented by product ID and it has several attributes: Product name, product description, product quantity, product price, product section, product color, product collection, product category and units sold which is a derived attribute. Product has a binary relationship with Cart and Line Item. With Cart, a product may be associated with 1 cart, and a cart will have zero or many products inside it. When it comes to Product and Line Item, a product may have zero or more line items and a line item may have one product associated with it.

Top: has four direct attributes given to it. These are: topFit, topSize, and topType. The above attributes of the entity, Product may also be given to Top through inheritance, in a mandatory, or relationship.

Bottom: has three direct attributes given to it. These are: bottomFit, and bottomSize. The above attributes of the entity, Product may also be given to Bottom through inheritance, in a mandatory, or relationship.

Shoes: has two direct attributes given to it. These are: usSize and euSize. The above attributes of the entity, Product may also be given to Shoes through inheritance, in a mandatory, or relationship.

5. Translating ERD

5.1 Relational Schema

Customer(customerID, fName, mName, lName, phone, email, street, city, state, zip)

Payment(paymentID, paymentType, paymentDigits, paymentCompany)

Product(productID, productName, productDescription, productQuantity, productPrice, productSection, productColor, productCollection, productCategory)

Orders(orderID, shippingCost, orderTimestamp , customerID, paymentID)

FOREIGN KEY (customerID) REFERENCE Customer(customerID) ON DELETE CASCADE

FOREIGN KEY (paymentID) REFERENCE Payment(paymentID) ON DELETE CASCADE

Shipment(trackingNo, orderID , street, city, state, zip, shippingCompany)

FOREIGN KEY (orderID) REFERENCE Orders(orderID) ON DELETE CASCADE

LineItem(line#, orderID , quantity, discount, productID )

FOREIGN KEY (orderID) REFERENCE Orders(orderID) ON DELETE CASCADE

FOREIGN KEY (productID) REFERENCE Product(productID) ON DELETE CASCADE

Returns(orderID, productID, returnDate, quantity)

FOREIGN KEY (orderID) REFERENCE Orders(orderID) ON DELETE CASCADE

FOREIGN KEY (productID) REFERENCE Product(productID) ON DELETE CASCADE

Cart(customerID, productID, quantity)

FOREIGN KEY (customerID) REFERENCE Customer(customerID) ON DELETE CASCADE

FOREIGN KEY (productID) REFERENCE Product(ProductID) ON DELETE CASCADE

Shoes(shoesID, usSize, euSize)

FOREIGN KEY (shoesID) REFERENCE Product(productID) ON DELETE CASCADE

Top(topID, topFit, topSize, topType)

FOREIGN KEY (topID) REFERENCE Product(productID) ON DELETE CASCADE

Bottom(bottomID, bottomFit, bottomSize, bottomType)

FOREIGN KEY (bottomID) REFERENCE Product(productID) ON DELETE CASCADE

5.2 Referential Integrity

9.4 Queries by Trim Kerwin

Number of Items sold after February 1st, 2021:

Bottom Inventory: Print all bottoms name, the initial amount in inventory and the amount of items sold.

Number of orders by State: print state and the number of orders made by customers from each state. Order by the count of orders made in a descending order.

Top products that are in the women section: Print product name, category, fit, type and size for every top in the women section:

10. Data Manipulation (Update and Delete)

10.4 Queries by Trim Kerwin

Delete a Shipment:

Update a Shipment:

11.4 Summary by Trim Kerwin

The goal of this project was to develop a functional system that grants users an intuitive online shopping experience. To achieve this, we created a database which encompasses the fundamental aspects of an e-commerce store. This database included customer information, order information, payment information and product information in the categories of shoes, top and bottom. With more time, this project’s shipping and return option would have been expanded for the customer’s convenience to include locations geared towards this service. The selection of products would have also be expanded to include hats and other items. With each passing week, I have learned a great deal about the fundamentals of database management as well as improving my knowledge of other platforms such as draw.io and GitHub for collaborative purposes. Due to the model of database development process, my team and I were able to design an ER model of the project after researching the requirements of the users. This ER model was then later translated to a relational model and then finally converted to a well-built SQL database.

11. Appendix – Division of work

This group has worked cohesively on this project from the initial steps of the design and ideas behind the online retail store to the completion of the relational schema, data dictionary, and SQL commands. The individuals within the group each completed their own rendition of queries, data manipulation, and summaries separate from the others, but all other work is to be divisible in equal parts. Overall, the work was competently spread throughout the group members and communication was frequent in order to achieve completion.

References

  1. The United States Census Bureau, 2019 E-Stats Report: Measuring the Electronic Economy, August 05, 2021.