By Adison Tan
Video overview:
The database for Smash Lab houses all objects that allow accurate identification of the stakeholders involved in transactions made in a badminton corner shop that strings badminton rackets. Additional information includes that to facilitate the process of these transactions, to improve satisfaction of customers and shop operability for owners.
As such, the scope of the database and its entities is as follows:
- Customers, including their identifying information.
- Staff, including their identifying information.
- Strings, including their specifications, pros/cons, endorsed players their cost per pc.
- Orders, including their total cost, collection date and the customer that created the order.
- String Job, including this single job cost, customer and staff involved in this job, and job comments.
The Smash Lab Database will allow users to perform the following:
- Allow staff to view their transaction histories.
- Allow staff to view basic information regarding their customer base such as their contact number, racket model and racket strings.
- Allow customers to place stringing orders online.
- Allow staff to track pending stringing orders in the job queue.
- Allow staff to update customers on their order status.
- Enable contactless racket collection through providing of locker number and password.
- Allow customers access to information to support their string purchase decisions.
Entities are captured in SQLite tables with the following schema.
The entities included in this database are illustrated as follows:
The customers table includes the following:
id, specifies the unique ID for the customer as anINTEGER. As such, this column will have thePRIMARY KEYconstraint applied.first_name, specifies the customer's first name asTEXT.last_name, specifies the customer's last name asTEXT.contact_number, specifies the customer's mobile phone number asINTEGER. This value has theNOT NULLconstraint applied to ensure a means of communication between the staff and their customers. This value also has theUNIQUEconstraint to prevent the creation of duplicate customer accounts.start_date, specifies the date at which the customer's first transaction was made with Smash Lab asNUMERIC. The default value for thestart_dateattribute is the current timestamp, as denoted byDEFAULT CURRENT_TIMESTAMP.
The staff table includes the following:
id, specifies the unique ID for the staff as anINTEGER. As such, this column will have thePRIMARY KEYconstraint applied.first_name, specifies the customer's first name asTEXT.last_name, specifies the customer's last name asTEXT.contact_number, specifies the staff's mobile phone number asINTEGER. This value has theNOT NULLconstraint applied to ensure a means of communication between the staff and their customers. This value also has theUNIQUEconstraint to prevent the creation of duplicate staff accounts.
The strings table includes the following:
id, specifies the unique ID for the strings offered by the shop as anINTEGER. As such, this column will have thePRIMARY_KEYconstraint applied.brand, specifies the name of the brand that created and supplies the following string asTEXT. This column will have theNON-NULLconstraint since each string must have a brand that supplied them.name, specifies the unique name for the strings offered by the shop as aTEXT. This column will have theUNIQUEconstraint applied to prevent duplicate string entries and aNOT NULLconstraint to allow matching of the ids to the strings.specification, specifies the racket string details asTEXT.pros, specifies the racket string advantages asTEXT.cons, specifies the racket string disadvantages asTEXT.endorsed_players, specifies the name of the players that use the following string asTEXT.price, specifies the cost of the string specified per piece as aNUMERIC. This column will have theNOT NULLconstraint to ensure consistency in the string prices issued to customers.
- Attributes such as
specifications,pros,consandendorsed_playerswill not contain theNOT NULLconstraint since they are information that are deemed as non-crucial.
The orders table includes the following:
id, specifies the unique ID for an order as anINTEGER. As such, this column will have thePRIMARY KEYconstraint applied.customer_id, specifies the unique ID for the customer who created this transaction as anINTEGER. This column thus has theFOREIGN KEYconstraint applied, referencing theidcolumn in thecustomerstable to ensure data integrity.locker_id, specifies the unique locker number, subject to the number of lockers purchased, as anINTEGER.locker_password, specifies the unique locker password, as a random 6-digitINTEGER.collection_status, specified the collection status for an order asTEXT. This attribute will have aCHECKconstraint with the following options ('In-Store', 'Ready For Collection', 'Collected').
- A single order can be a culmination of multiple string jobs
GROUP BYthecustomer_id. However, since there can be returning customers, we will furtherGROUP BYthe attributesjob_statusandcollection_status, if necessary, to ensure that the orders accurately reflects the most recent transactions and not include past, completed ones. - All attributes with
CHECKconstraints can have their options expanded, subject to the availability of products procured by the shop that is adopting Smash Lab. - The
locker_idandlocker_passwordattributes do not have aNOT NULLconstraint as these values will be NULL until the lockers can be allocated upon completion of string jobs.
The string_job table includes the following:
id, specifies the unique ID for a stringing job as anINTEGER. As such, this column will have thePRIMARY KEYconstraint applied.customer_id, specifies the unique ID for the customer who created this transaction as anINTEGER. This column thus has theFOREIGN KEYconstraint applied, referencing theidcolumn in thecustomerstable to ensure data integrity.staff_id, specifies the unique ID for the staff who facilitated this transaction as anINTEGER. This column thus has theFOREIGN KEYconstraint applied, referencing theidcolumn in thestafftable to ensure data integrity.order_id, specifies the unique ID for the order at which this individual string job belongs to as anINTEGER. This column thus has theFOREIGN KEYconstraint applied, referencing theidcolumn in theorderstable to ensure data integrity.string_id, specifies the unique ID for the string to be used for the racket in this order as anINTEGER. This column thus has theFOREIGN KEYconstraint applied, referencing theidcolumn in thestringstable to ensure data integrity.string_colour, specifies the colour of the string to be used for the particular racket in this job asTEXT. This attribute will have aCHECKconstraint with the following options ('White', 'Red', 'Yellow', 'Blue').string_tension, specifies the tension of the string to be strung for this particular racket asINTEGER. This column has theNOT NULLconstraint since this is crucial information for every stringing job. It also has aCHECKconstraint to ensure that the tension input is within the range of 22 lbs to 34 lbs.comments, specifies the description of the racket involved in this transaction, such as the racket model, racket colour and grip type asTEXT. TheNOT NULLconstraint has to be applied to this attribute to ensure correct matching of string choice to each racket.job_cost, specifies the cost of this single transaction asREAL.job_status, specifies the status of completion for this single transaction asTEXT. This attribute will have aCHECKconstraint with the following options ('Pending', 'Completed').
- The
NOT NULLconstraint has to be applied across bothjob_statusandcollection_statusto ensure that proper identification and grouping of orders is possible at all times. - The
job_statusandcollection_statusattributed will also have DEFAULT entries 'Pending' and 'In-Store' respectively. These statuses will be updated as the jobs progress along.
The following are the justifications for the indexes created to optimise Smash Lab's common queries.
- With reference to the commonly made queries with Smash Lab in
sql/queries.sql, searching by bothcollection_statusandjob_statusis imperative for facilitating efficient and smooth locker usage. As such, indexes are created on thecollection statuscolumn inordersandjob_statuscolumn instring_jobto speed up search by both attributes. - Many queries in
sql/queries.sqlalso filter information crucial to shop operability such as order details and order/shop pricing using theorder_idcolumn. As such, indexes are created on theorder_idcolumns to speed up searches by this attribute. - These choices are measured in
benchmark/RESULTS.md. On a synthetic dataset of 50,000 orders and 90,034 string jobs, the indexes cut the total time for the seven common queries from about 5.6 s to 31 ms. The index oncollection_statusgives no gain for "lockers to reclaim", since about 97% of orders areCollectedand the index barely narrows the search.
The following are limitations of Smash Lab.
- Staff are unable to reply to comments sent in with customer orders for a stringing job. As such, staff will have to message customers externally to facilitate these communications.
- Expiry dates on the collection lockers are not implemented in this iteration but can be further expanded on through future iterations of Smash Lab.
- The ease of identification of a customer's racket to match their strings can be challenging, especially if a customer has identical rackets. As such, the ease of this process becomes highly dependent on the details given by the customers in their
commentsfrom thestring_jobtable, which is hard to control.
