As you can see, it??™s easy to use Active Record
to process data.
Summary
In this chapter, you got started using MySQL and Active Record with Ruby to produce
some simple reports. Active Record is a powerful, easy-to-use library. Although Active
Record is best known for web applications, it can be used quickly and easily for virtually
all types of Ruby database connectivity, including reporting.
In both the examples in this chapter, you did all of the statistical calculations manually
in Ruby code. Instead, you can use MySQL??™s and Active Record??™s statistical functions
to get statistics, group data, and more. The next chapter covers calculatiing statistics with
Active Record.
CHAPTER 1 n DATA ACCESS FUNDAMENTALS 17
Calculating Statistics with
Active Record
The previous chapter discussed the fundamentals of accessing and manipulating data
with Active Record. The statistical analyses??”the highest salary, average salary, and so
forth??”were done manually using Ruby code. While that??™s a plausible approach, it??™s easier
and often quicker to let the database do the work for you.
Pages:
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53