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 Score
tables. Transportation Service Provider Performance
table excludingaward_count
field. This table has all relevant information fromBest Value Score
,Quality Band Assignment
, andPerformance Period
tables. Those tables do not exist. JoinShipment Awards
table onTDL
to determine the number of shipments already awarded to TSP (known as award count).Transportation Service Provider Performance
table includingaward_count
field. This is the sameTransportation Service Provider Performance
table as described above, with the addition of anaward_count
field, obviating the need for a join between theShipment Awards
and TSP performance tables to determine TSP award counts. Ends up denormalizing data fromShipment Awards
table.
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
BVS
table 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_count
does not get out of sync with our source of truth, theShipment Awards
table. We also are still not totally clear how to index our newTransportation Service Provider Performance
table 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 Scores
table with anID
,TDL
andTSP
foreign keys, and aBVS
.Quality Band Assignment
table withID
,band_number
,performance_period
, number ofshipments_per_band
, andTSPs
andTDL
foreign keys.Performance Period
table 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_ids
field, 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_count
derived fromshipment_awards
-
Requires joiningshipment_awards
totransportation_service_provider_performance
and 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.