Ruby on Rails Sunday, January 4, 2015

On 4 January 2015 at 21:50, D.c. Zzz <lists@ruby-forum.com> wrote:
> I'm using Rails 4 and the testing framework with which it ships.
>
> I'm using a relational database that needs to be rigorously tested for
> internal consistency. In this case, it's a sports statistics database
> with player stats that are updated nightly.
>
> I need to run tests like the following when new data arrives each night:
> --That the sum of player stats equals the team's.
> --That the sum of team stats equals the league's.
> --That the sum of wins and losses equals games played.
> --etc.

I would start by, as far as practical, normalising the database so
that there are no such potential inconsistencies.

Next if it is suggested that it is not practical to fully normalise it
then probe the logic behind that carefully to make sure it is really
true. Do not just assume that something that seems like a good idea
from the performance aspect is necessarily worthwhile. Decades of
experience in the S/W industry has shown time and again that the
bottlenecks in an app are virtually never where they are initially
anticipated.

Next if it is absolutely not practical to fully normalise it then
arrange all updates using transactions such that if an inconsistency
arises it must be a bug.

Next have a comprehensive set of automatic tests that attempt to get
inconsistent data into the database.

Finally have a task which is run on the server at appropriate times,
possibly via cron or automatically invoked when data are updated, that
performs the checks and sounds a siren if a bug is detected.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLttEQ%3DpNbAuY0ex9-ZyTQu35N_vmaz5RwcCSE0ChcveDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment