The TSP Data Models
User Story: 155524224
The TSP Award Queue needs to be able to access information from the database efficiently enough to award shipments to TSP based on TDL, Performance Period, Best Value Score, Quality Band, and number of shipments already awarded. Decision drivers included the anticipated format of frequent queries, query speed, and size of data.
Considered Alternatives
- Separate
Quality Band Assignment,Performance Period, andBest Value Scoretables. Transportation Service Provider Performancetable excludingaward_countfield. This table has all relevant information fromBest Value Score,Quality Band Assignment, andPerformance Periodtables. Those tables do not exist. JoinShipment Awardstable onTDLto determine the number of shipments already awarded to TSP (known as award count).Transportation Service Provider Performancetable includingaward_countfield. This is the sameTransportation Service Provider Performancetable as described above, with the addition of anaward_countfield, obviating the need for a join between theShipment Awardsand TSP performance tables to determine TSP award counts. Ends up denormalizing data fromShipment Awardstable.
Decision Outcome
Chosen Alternative: Transportation Service Provider Performance table including award_count field
Justification: Originally, the proposal included the three separate tables detailed in alternative 1. After realizing we'd be unable to pursue this route for the reasons described below, we concluded that a table that included the BVS information and quality band information was logical, since the latter depends on the former. After making this decision, it was clear the
BVStable no longer contained information specific to BVS. So we began considering it a table to representTransportation Service Provider Performance, which is what determines the order and number of shipments awarded to each TSP.Consequences: Denormalization means that we have to be vigilant that the
award_countdoes not get out of sync with our source of truth, theShipment Awardstable. We also are still not totally clear how to index our newTransportation Service Provider Performancetable so that we can reap the benefits of indices without bloating our table with them.
Pros and Cons of the Alternatives
Quality Band Assignment, Performance Period, Best Value Score tables
This was the original proposal. It included the following 3 tables:
Best Value Scorestable with anID,TDLandTSPforeign keys, and aBVS.Quality Band Assignmenttable withID,band_number,performance_period, number ofshipments_per_band, andTSPsandTDLforeign keys.Performance Periodtable withID,start_date, andend_date.
We quickly discovered blockers we could not ignore.
+Separate interests+Conceptually easy to understand-DEALBREAKER: Made impossible assumptions (for example, included atransportation_service_provider_idsfield, which would have called for a 1:many. It is not be possible to point from the 1 quality band to many TSPs, which is the direction 1:many relationships are oriented).-Would need to JOIN quality band assignment and performance period tables first to determine quality bands and then to determine which TSPs are next in line to receive shipment awards.
Transportation Service Provider Performance table excluding award_count field
+Same pros as chosen alternative+Does not denormalize data by havingaward_countderived fromshipment_awards-Requires joiningshipment_awardstotransportation_service_provider_performanceand iterating through all the TSPs in the relevant TDL to determine the next TSP to award a shipment to. This join was thought to be prohibitively slow for a query that would be made fairly frequently.