Mailing List Archive

Shipping in Interchange 6
Hello,

we revised our ideas with the handling of shipping methods and shipping prices in Interchange6.

Basically we will have the following classes:

* ShipmentCarrier

UPS, DHL, ...

* ShipmentMethod

Each carrier can have multiple shipment methods like

Ground, NextDay, Europe Express, ...

* ShipmentRate

Each method can have multiple shipment rates depending
on shipment conditions (weight, subtotal, postal code range)

* ShipmentCondition

The conditions are in a tree structure and a shipment rate belongs
the root node of one these conditions.

Examples:

weight between 0 and 50 AND postal code between 10000 and 109999
subtotal between 0 and 200
pending order for this user

Based on this we implement two important methods.

The first one provides a list of available shipping methods and the second
one the shipping rate (price), depending on the following parameters:

subtotal, zip, state, country, weight (you can add more parameters if your
condition needs them).

You will certainly have a way to hook into these methods to change the
result of the calculation.

There are several ways to storing trees in a RDBMS, each with its own pros and cons:

Adjacency list
Nested set
Closure table (aka bridge table)
Materialized path (path enumeration)

Opinions on these are:

ribasushi prefers materialized path, he said it scales linearly and is easy to shuffle.
Peter Mottram pointed out that closure table looks interesting and means a drag and drop gui can be used to make changes.
Moritz Lenz said that has been happy with Nested Sets for read-heavy workloads.

We are going to evaluate these for shipping conditions, but your input is most welcome.

References:

https://metacpan.org/pod/DBIx::Class::MaterializedPath
http://bojanz.wordpress.com/2014/04/25/storing-hierarchical-data-materialized-path/
http://www.slideshare.net/billkarwin/models-for-hierarchical-data

Regards
Racke

--
Perl and Dancer Development

Visit our Perl::Dancer conference 2014:

http://act.perl.dance/

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: Shipping in Interchange 6 [ In reply to ]
> The conditions are in a tree structure and a shipment rate belongs
> the root node of one these conditions.

I'm not sure why this warrants the complexity of a tree (perhaps a
better example?), but:

> Adjacency list
> Nested set
> Closure table (aka bridge table)
> Materialized path (path enumeration)

Adjacency list should be ruled out if we still want to support MySQL (no CTEs!)

I think any of the others will be fine. The data set will be so small I don't
think relative read or write speed should really matter. I would find one
that is familiar to whomever wants to champion/write it. FWIW, I prefer
nested set for smallish data sets.

--
Greg Sabino Mullane greg@endpoint.com
End Point Corporation
PGP Key: 0x14964AC8
Re: Shipping in Interchange 6 [ In reply to ]
On 07/26/2014 05:34 AM, Greg Sabino Mullane wrote:
>> The conditions are in a tree structure and a shipment rate belongs
>> the root node of one these conditions.
>
> I'm not sure why this warrants the complexity of a tree (perhaps a
> better example?), but:
>
>> Adjacency list
>> Nested set
>> Closure table (aka bridge table)
>> Materialized path (path enumeration)
>
> Adjacency list should be ruled out if we still want to support MySQL (no CTEs!)
>
> I think any of the others will be fine. The data set will be so small I don't
> think relative read or write speed should really matter. I would find one
> that is familiar to whomever wants to champion/write it. FWIW, I prefer
> nested set for smallish data sets.

Thanks for your advice. If we could avoid the complexity of a tree,
that would be good. Do you have a suggestion how to structure the
shipment conditions into a linear fashion in the database?

Regards
Racke



--
Perl and Dancer Development

Visit our Perl::Dancer conference 2014:

http://act.perl.dance/

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users