Database Reference
In-Depth Information
Figure 12.7. A partial sample of data from the CLASS REGISTRATION view
In order to answer your question, you must now count each instance of a given class name
sothatyoucandeterminehowmanystudentsareregisteredforthatclass.Imaginethework
you have ahead of you—this will not be an easy task! Rather than going through all this
tedious work, you can answer your question quite easily (and more efficiently) using an
aggregate view.
There's no need to define a new view because you can modify the one you have just now.
Remove the S TUDENT ID field from the view and replace it with a calculated field called
T OTAL S TUDENTS R EGISTERED thatcountsthenumberofstudentsperclass.(Whenyouwork
withacalculatedfield,makecertainthatyougiveitanamethatismeaningfulandthatwill
distinguishitfromothercalculatedfieldsintheview.)ThecalculatedfieldwilluseaCount
function to count the number of S TUDENT IDs in the STUDENT CLASSES table that are
associated with each C LASS ID in the STUDENT CLASSES table. (Later, you'll learn how
to document a view and record the expression the calculated field will use.) Figure 12.8
shows the revised diagram for the CLASS REGISTRATION view.
Search WWH ::




Custom Search